DMP - Chapter 4

Character Strings and Formatted I/O

#include <stdio.h> #define DAYS 365 #define RENT 1234.56 #define AGE 31 #define BLURB "Digtal Music" void main(void) { printf("/%d/\n", DAYS); printf("/%2d/\n", DAYS); printf("/%10d/\n", DAYS); printf("/%-10d/\n", DAYS); printf("/%f/\n", RENT); printf("/%e/\n", RENT); printf("/%4.2f/\n", RENT); printf("/%3.1f/\n", RENT); printf("/%10.3f/\n", RENT); printf("/%10.3e/\n", RENT); printf("/%+4.2f/\n", RENT); printf("/%010.2f/\n", RENT); printf("%x %X %#x %#X\n", AGE, AGE, AGE, AGE); printf("**%+d**% d**%+d**% d\n", AGE, AGE, -AGE, -AGE); printf("**%5d**%5.3d**%05d**%05.3d**\n", AGE, AGE, AGE, AGE); printf("/%2s/\n", BLURB); printf("/%12s/\n", BLURB); printf("/%12.5s/\n", BLURB); printf("/%-12.5s/\n", BLURB); printf("/% 12s/\n", BLURB); }

Find the errors:

include <stdio.h>
        float g; h;
        float tax, rate;

        g = e21;
        tax = rate * g;

Find the errors:

void main(int) / this program is perfect / 
cows, legs integer; 

Go to the Ich's Home Page

Go to the Peabody Home Page

For comments or questions email to: