| types/float-prog.c - Et C program som illustrerer ovenstående. | Lektion 8 - slide 12 : 29 Program 1 |
#include <stdio.h>
int main(void) {
float f = 123.456F;
double d = 123.456;
long double ld = 123.456L;
// Printing the 3 variables of different types:
printf("float: %f, double: %f, long double: %Lf\n", f, d, ld);
// Scanning the 3 variables:
printf("Enter new values: ");
scanf(" %f %lf %Lf",&f, &d, &ld);
// Printing again:
printf("float: %f, double: %f, long double: %Lf\n", f, d, ld);
return 0;
}