Home >>c programs >c program to find sum of two numbers

c program to find sum of two numbers

Write a Program to Sum of two number input given by user

In c language the addition of two numbers is the arithmetic operation of adding them and printing the sum of both two numbers on the screen.

For display the sum of these numbers we are using printf() function.

For example-the input is 10 and 20 the output is 30.

Let's take an example :

#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:10
enter second number:20
sum of 2 numbers:30
Output :
enter first number:100
enter second number:50
sum of 2 numbers:150

No Sidebar ads