Page 9 - PROGRAMMING IN C_Neat
P. 9

9. Explain the formatted input and output functions in detail. ***

        Formatted Input Function:
         scanf() function is called Formatted Input Function.
         General Form:

                       scanf(“control string”, &variable1, &variable2, … &variable n);

         General Form of control string;: %w data_type
          Conversion Character Table:

                     Data        Conversion
                     Type        Character
                     char                %c
                     int                 %d
                     float               %f
                     string              %s
         Example:
               int  a;
               scanf(“%d”, &a);

        Formatted Output Function:
         printf() function is called Formatted Output Function.
         General Form:

                       printf(“control string”, variable1, variable2, … variable n);

         General Form of control string: %w.p data_type
          Conversion Character Table:

                     Data        Conversion
                     Type        Character
                     char                %c
                     int                 %d
                     float               %f
                     string              %s

         Printing Integer:
          Example:
               int  x = 2000;         Output:
               printf(“%d”, x);
         Printing Float:           2  0  0  0
          Example:
               float  x = 123.4567      Output:
               printf(“%8.4f”, x);                     4  5  6  7
                                       1  2  3  .
         Printing String:
          Example:
               name = “Kandan”;       Output:
               printf(“%s”, name);        K  a  n  d  a  n


        _______________________________________________________________________________________
   4   5   6   7   8   9   10   11   12   13   14