Algorithm:
1.Start the program
2.Read two numbers from users
3.Add two numbers using addition operator
4.Print the sum value
5.Stop the program
C program - Sum of two numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int num1,num2,num3;
clrscr();
printf("Enter first number \n");
scanf("%d",&num1);
printf("Enter second number \n");
scanf("%d",&num2);
num3 = num1+num2;
printf("sum is %d \n",num3);
getch();
}
Output for Sum of two numbers c program
Enter first number
10
Enter second number
20
sum is
30
Result:
Thus the c program to add two numbers is written and executed successfully.
1.Start the program
2.Read two numbers from users
3.Add two numbers using addition operator
4.Print the sum value
5.Stop the program
C program - Sum of two numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int num1,num2,num3;
clrscr();
printf("Enter first number \n");
scanf("%d",&num1);
printf("Enter second number \n");
scanf("%d",&num2);
num3 = num1+num2;
printf("sum is %d \n",num3);
getch();
}
Output for Sum of two numbers c program
Enter first number
10
Enter second number
20
sum is
30
Result:
Thus the c program to add two numbers is written and executed successfully.