| implicit-conversions.c - Eksempler på implicitte typekonverteringer. | Lektion 5 - slide 14 : 24 Program 1 |
#include <stdio.h>
int main(void) {
short s = 12; char c = 'a';
double d = 123456.7; float f = 4322.1;
int i;
printf("c - s = %i is converted to int\n", c - s);
/* The type of c - s is promoted to int */
printf("d + f = %f is converted to a double\n", d + f);
/* f is converted to double before adding the numbers */
i = d;
printf("In assigning d to i %f is demoted to the int %i\n", d, i);
/* d is converted to an int - information is lost */
return 0;
}