Program to find sum of two numbers using c programming language.
C Programming Language Fundamentals of C Language (Article) Fundamentals of C Language (Program)
11815Program:
#include"stdio.h" void main() { int num1, num2, sum; printf("Enter two no: "); scanf("%d%d",&num1,&num2); sum = num1 + num2; printf("sum=%d \n", sum ); }
Output:
Enter two no: 2 3 sum=5 Press any key to continue . . .
Explanation:
Algorithm:
- Step 1: Start
- Step 2: Declare variable number1, number2 and sum
- Step 3: Read Variable number1, number2
- Step 4: Perform operation (sum= number1+ number2)
- Step 5: Print sum variable
- Step 7: Stop
In this program, the user is asked to enter two integers. These two integers are stored in variables number1 and number2 respectively.
printf("Enter two integers: ");
scanf("%d %d", &num1, &num2);
Then, these two numbers are added using the +
operator, and the result is stored in the sum variable.
sum = num1 + num2;
Finally, the printf()
function is used to display the sum of numbers.
printf("sum=%d \n", sum );
This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.