C program to read two values from user and print there sum.
Q4. Write a C program to read two values from user and print there sum.
Solution:
#include<stdio.h> //standard input/output header file
#include<conio.h> //for clrscr()
int main()
{
int value1,value2,sum;
clrscr(); //to clear the screen
printf(“\n Enter first value: “);
scanf(“%d”,&value1);
printf(“\n Enter second value: “);
scanf(“%d”,&value2);
sum=value1+value2;
printf(“\n The sum of given numbers is: %d”,sum);
getch();//holds the screen until a key is pressed
return 0;//makes the main() to finish
}
OUTPUT:
Enter first value: 5
Enter second value: 6
The sum of given numbers is: 11