Write a program that illustrates the run time field width and precision adjustment while using printf( ).
C Programming Language Loop control in C Language (Article) Loop control in C Language (Program)
1347Program:
/* Program: Write a program that illustrates the run time field width and precision adjustment while using printf( ). Author: www.atnyla.com */ #include "stdio.h" int main() { double x=1234.567890; int i=8,j=2; while(i<12) { j=2; while(j<5) { printf("width = %2d precision = %d display >>%*.*lf<<\n",i,j,i,j,x); j++; } i++; } return 0; }
Output:
width = 8 precision = 2 display >> 1234.57<< width = 8 precision = 3 display >>1234.568<< width = 8 precision = 4 display >>1234.5679<< width = 9 precision = 2 display >> 1234.57<< width = 9 precision = 3 display >> 1234.568<< width = 9 precision = 4 display >>1234.5679<< width = 10 precision = 2 display >> 1234.57<< width = 10 precision = 3 display >> 1234.568<< width = 10 precision = 4 display >> 1234.5679<< width = 11 precision = 2 display >> 1234.57<< width = 11 precision = 3 display >> 1234.568<< width = 11 precision = 4 display >> 1234.5679<< Press any key to continue . . .
Explanation:
None
This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.