printf() and scanf() functions are used for input and output and it is inbuilt library function define in #include<stdio.h> header file.
Printf() function:
- Printf() function is used to print message / argument / output.
- It print given argument.
Printf() function Syntax:
- printf("format string",argument_list);
The format string can be %d (integer), %c (character), %s (string), %f (float) etc.
Scanf() function:
- Scanf() function is used to read data from user.
- Scanf() function is used for input.
Scanf() function Syntax:
- scanf("format string",argument_list);
The format string can be %d (integer), %c (character), %s (string), %f (float) etc.
Example
- #include<stdio.h>
- int main(){
- int marks;
- printf("Enter a Marks:");
- scanf("%d",&marks);
- printf("You have enter marks is:%d ",marks);
- }
The scanf("%d",&marks) statement reads integer number from the console and stores the given value in number variable.
0 Comments: