A program that prints out numbers on the screen using different formatted placeholders.
#include <stdio.h> int main (void) { /* declarations */ int a; double x; /* executable statements */ a = 1000; x = 100.583665; printf ("%d\n", a); printf ("%3d\n", a); printf ("%4d\n", a); printf ("%5d\n", a); printf ("\n"); printf ("%lf\n", x); printf ("%15lf\n", x); printf ("%15.4lf\n", x); printf ("%18.2lf\n", x); printf ("%12.0lf\n", x); return (0); } |
1000
1000
1000
1000
100.583665
100.583665
100.5837
100.58
101
|
No comments:
Post a Comment