DMP - Chapter 4

Character Strings and Formatted I/O

#include <stdio.h>
#define DAYS 365
#define RENT 1234.56
#define AGE  31
#define BLURGB "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);

Assignment #4: Due Oct. 10, 1995.

p. 117: #1, 2, 3, 4
Go to the Ich's Home Page

Go to the Peabody Home Page

For comments or questions email to: