Mega Code Archive

 
Categories / C Tutorial / Printf Scanf
 

Use scanf to get input from a standard input device, such as a keyboard

In scanf, you have to specify the address of a variable, such as &i, &j, and a list of format specifiers (%d). The number of format specifiers must be the same as the number of variables. #include <stdio.h> main(){   int i,j,k;   printf("Input two integers and press Enter to comfirm:");   scanf("%d%d",&i,&j);   k = i + j;   printf("sum of two numbers is %d \n",k); } Input two integers and press Enter to comfirm:223 2 sum of two numbers is 225