Give the output on the screen of the following program
#include <stdio.h>
#define PR(x) printf(#x " = %.8g\t",(double)x)
#define NL putchar('\n');
#define PRINT4(a,b,c,d) PR(a);PR(b);PR(c);PR(d);NL
int main()
{
double d;
float f;
long l;
int i;
i = l = f = d = 100/3; PRINT4(i,l,f,d);
d = f = l = i = 100/3; PRINT4(i,l,f,d);
i = l = f =d = 100/3.; PRINT4(i,l,f,d);
d = f = l = i = (double)100/3; PRINT4(i,l,f,d);
i = l = f = d = (double)(100000/3);PRINT4(i,l,f,d);
d = f = l = i = 100000/3 ; PRINT4(i,l,f,d);
return 0;
}
Difficulty level
This exercise is mostly suitable for students
i = 33 l = 33 f = 33 d = 33
i = 33 l = 33 f = 33 d = 33
i = 33 l = 33 f = 33.333332 d = 33.333333
i = 33 l = 33 f = 33 d = 33
i = 33333 l = 33333 f = 33333 d = 33333
i = 33333 l = 33333 f = 33333 d = 33333
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Bellman-Ford Algorithm