Mega Code Archive

 
Categories / C Tutorial / Printf Scanf
 

Using Scanf to Receive Input from a User

#include <stdio.h> main(){   int iOperand1 = 0;   int iOperand2 = 0;   printf("\nEnter first operand: ");   scanf("%d", &iOperand1);   printf("Enter second operand: ");   scanf("%d", &iOperand2);   printf("The result is %d\n", iOperand1+iOperand2); } Enter first operand: 1 Enter second operand: 2 The result is 3