Monday, August 14, 2017

C programming;Lesson 6: Operators for formatting the output

Special Signs for Surveillance:
                       constance                                                   meaning 
                            \b                                               movement for one place left                                                                     \n                                                            new line                                                                                       \f                                                           new page                                                                                       \t                                                       horizontal tab                                                                                   \"                                                      quotation letter                                                                                   \\                                                    backslash character 
                            \?                                                      question mark

Example: 
              printf ("This is the first line. \n"); 
              printf ("This is the second line");
              printf ("\n \tThis is the third line and moved to the right");

Additional forms of variable formats:
The format "%2d" determines that the variable is a two-digit number.

Example: 
                 int a; 
                 scanf ("%2d", &a);
                 printf ("%d");


The format "% .2f" determines that the variable is a real number written in decimal form with two decimal places.
Example: 
                 float a;
                 scanf ("%f", &a);
                 printf ("%.2f", a);










1 comment: