1 / 2

Making the PRINTF Look Better in G05 !!

Making the PRINTF Look Better in G05 !!. EXAMPLE: printf ("%f%d", a, b) ; /* Produces lots of decimal places for variable ‘a’….. 142.101567 … defaults to 6 */ But you can control the output as follows:

Download Presentation

Making the PRINTF Look Better in G05 !!

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Making the PRINTF Look Better in G05 !! EXAMPLE: printf ("%f%d", a, b) ; /* Produces lots of decimal places for variable ‘a’….. 142.101567 … defaults to 6 */ But you can control the output as follows: printf ("%x.yf%zd", a, b) ; /* The x & z specify the total number of defaultplaces (always supplied, more provided if needed) including the decimal point and any sign . The y specifies the exact number of place to the right of the decimal point. This control allows the programmer to better align output data. The x, y & z are optional. printf ("%.2f%d", a, b) ; /* Now produces only 2 places to the right of the decimal for variable ‘a’….. 142.10 */

  2. Example • Say you want to print • The pole is 42.735 feet high • The pole is 4.123 feet high • The pole is 192.678 feet high • You would use • printf (“The pole is %.3f feet high\n”,hgt);

More Related