Skip to main content

C: 5. printf() and scanf()

The printf() and scanf() functions are used for input and output in C language. Both functions are inbuilt library functions, defined in stdio.h (header file).

Let's Better Understand via the following code:- 

#include<stdio.h>    
int main(){    
int x=0,y=0,result=0;  
  
printf("enter first number:");  
scanf("%d",&x);  
printf("enter second number:");  
scanf("%d",&y);  
  
result=x+y;  
printf("sum of 2 numbers:%d ",result);  
  
return 0;  
  
Output:- 
enter first number:9
enter second number:9
sum of 2 numbers:18

Comments