Printf() Minimum Number on Print Table 1 in C Programming

Asked By 7060 points N/A Posted on -
qa-featured

What is the minimum number of printf() statements that could be used to print table1?

Why would you not write a program using the minimum number of printf() function calls?

Part no. Price

T1267 USD 6.34

T1300 USD 8.92

T3401 USD 65.40

T4482 USD 36.99

SHARE
Answered By 0 points N/A #84653

Printf() Minimum Number on Print Table 1 in C Programming

qa-featured

Hi,

Your table 1 has four lines and a heading. In order to print table 1 (not include heading), you have four printf() statements. But, if you use a loop statement (for, while, or do…while), you have just one printf() statement, and the program will call it x times, depends on number of lines in your table.

For example:

strict Price

{

      char partNo[6];

      float price;

}Table1;

void Print Price(Table1 tb[], int numOfLine)

{

       int id;

       printf(“Part No tt Pricen”);

       for(id=0; id<numOfLine; id++)

            printf(“%s t USD t %.2f n”, tb[id].partNo, tb[id].price);

}

Hope this helps

Login/Register to Answer

Related Questions