
Algorithms and Programs 67
The C programming languages provide several functions for console in-
put/output. The function for input reads the value of a variable from the input device.
The name of the function is scanf, and is used with a format operator. The general
form for input in C for reading the value of a numeric floating-point variable, var, is
shown in the following line of code.
scanf (" %lf", &var);
A string message is typically included to prompt the user for input of a data value.
This is implemented with the printf function. The previous example for reading the
value of variable y is written in C as follows:
printf ("Enter value of y: