As, everyone knows that how to find out the sum of two numbers. So, let's get started.
Logic to Solve Problem.
1. Take the input of two numbers
2. Add them, and
3. Finally, Print the value of the sum.
C program to enter two numbers and find their sum.
/* * Program to find the sum of two numbers */ #include<stdio.h> int main() { int a,b,sum; /* a and b for two numbers and sum for sum of two numbers. */ printf("Enter the first number\n"); // Input the first number scanf("%d",&a); printf("Enter the second number\n"); // Input the second number scanf("%d",&b); //this perform the sum sum = a + b; // For printing the sum values printf("Sum of two numbers %d and %d is %d.",a,b,sum); return 0; }
Output of the Above Program is:
Enter the first number 1453 Enter the second number 5362 Sum of two numbers 1453 and 5362 is 6815
I hope you know very well how to add two numbers in C language. If you like this posts. Then, Please Comment Us!
0 Comments