C – Scanf

C – Scanf 2017-07-19T19:21:20+00:00

Scanf :

  • The usually used input statement is scanf () function.

Syntax of scanf function is
scanf (“format string”, argument list);

  • The format string must be a text enclosed in double quotes. It contains the information for interpreting the entire data for connecting it into internal representation in memory.
    Example: integer (%d) , float (%f) , character (%c) or string (%s).
  • The argument list contains a list of variables each preceded by the address list and separated by comma.
  • The number of argument is not fixed; however corresponding to each argument there should be a format specifier. Inside the format string the number of argument should tally with the number of format specifier.

C -SCANF EXAMPLE PROGRAM :

if i is an integer and j is a floating point number, to input these two numbers we may use
scanf (“%d%f”, &i, &j);

Output :

Prev Next