Previous: 3.7 Summary
Up: 3 Designing Programs Top Down
Next: 3.9 Problems
Previous Page: 3.7 Summary
Next Page: 3.9 Problems
#define SQ(x) x * x;
printf("%d\n", SQ(3));
#define SQ(x) x * x;
printf("%d\n", SQ(2+3));
#define DEBUG 0
#define TWICEZ z + z
main()
{ int z = 5;
#ifdef DEBUG
printf("%d\n", TWICEZ * 2);
#endif
}
#include <stdio.h>
main()
{ float x, y, average;
printf("Type two numbers: ");
scanf("%f %f", &x, &y);
calc_avg(x, y);
printf("Average of %f and %f is %f\n", x, y, average);
}
calc_avg(float a, float b)
{
return a + b / 2;
}
main()
{ float x, y, average;
printf("Type numbers\n");
scanf("%f", &x);
while (x != EOF) {
printf("Number read = %f\n", x);
scanf("%f", &x);
}
}