Friday, 3 March 2017

Using Scanf statements



//This program is to add two numbers with scanf function!!!

#include<stdio.h>

int main()
{


// now lets get the data to be added from the User using a keyboard
int input1,input2,sum;
printf("add two numbers of your choice\n");
printf("Enter the first number\n");
//scanf is a inbuilt function which is defined in a stdio.h header file,it is used to read the data from the keyboard
scanf("%d",&input1);
// "&" here ampersand means address
// address of input1 is specified,so that the value is stored in the known address
printf("Enter the second number\n");
scanf("%d",&input2);
sum=input1+input2;
printf(" First_No that u entered:%d,\n Second_no that u entered:%d,\n therefore sum of two numbers:%d",input1,input2,sum);

}

No comments:

Post a Comment