In C inputting some data is done by scanf and outputting or printing the data on console (output screen) is done by printf statement. These are standard library functions. The way to write these statements is,
Input and Output Operations
In
C inputting some data is done by scanf and outputting or printing the data on
console (output screen) is done by printf statement. These are standard library
functions. The way to write these statements is,
scanf(format
specifier,variables);
Note
that the format specifier is %d since the val is an integer variable. Also the
val variable is taken with the & symbol. The & (ampersand) means
"address of". Any variable is referred by its address. It is
exactly similar to the way you find your friend, either by his address or by
his phone number. Thus any variable can be obtained by its address.
printf(format
specifier,variables);
For
example: printf("%d",val);
Note
that here there is no need of & because we are printing the value of val
variable. This value is already stored in some statement.
Even
the printf can also be used to simply print the message on the console.
C Programming and Data Structures: Unit I: C Programming Fundamentals : Tag: : C Programming - Input and Output Operations
C Programming and Data Structures
CS3353 3rd Semester EEE, ECE Dept | 2021 Regulation | 3rd Semester EEE Dept 2021 Regulation