C Program To Add Two Numbers

C Program To Add Two Numbers. If you are looking for the addition of two numbers program in C, here in this tutorial we will help you to learn how to write a c program to add two numbers.

C Program To Add Two Numbers

Just copy paste the below source code to add two numbers in C compiler to test, how the source code works. Debug and learn how it works. Happy coding.

C Program To Add Two Numbers Source Code

/* C Program To Add Two Numbers - AddTwoNumbers.C */

#include<stdio.h>
 
int main()
{
   int a, b, sum; //variable declaration
 
   printf("Enter two numbers to add: \n"); //asking user to enter numbers
   scanf("%d%d",&a,&b); //reading user entered numbers
 
   sum = a + b; //simple logic to add two numbers
 
   printf("Sum of entered numbers = %d\n",sum); //printing sum
 
   return 0;
}

C Program To Add Two Numbers Output

When you compile and run the above c program to add two numbers, your C compiler asks you to enter the two positive integers to add. After entering the numbers, C compiler will perform addition and display sum of the two numbers.

Output:

Enter two numbers to add: 10 20

Sum of entered numbers = 30

C PROGRAMMING EXAMPLES

  1. C Program To Reverse A Number
  2. C Program to Find Maximum and Minimum Numbers
  3. C Program to Read a Text File
  4. C Program to Convert Decimal to Hexadecimal
  5. C Program to Convert Decimal to Binary
  6. C Program to Convert Celsius to Fahrenheit
  7. C Program To Find Absolute Value
  8. Ternary Operator Program in C
  9. C Program For Addition Table Using For Loop
  10. Denomination Program in C
  11. C Program to Print Multiplication Table 
  12. C Program Array with Example
  13. Binary Search in C Program Using Recursion
  14. Bubble Sort in C Using Pointers
  15. Bubble Sort Program in C Using Recursion
  16. Bubble Sort Program in C Using Array
  17. Bubble Sort Program in C Using Function
  18. Bubble Sort Program in C Using Linked List
  19. Stack Push Pop Program in C Using Arrays
  20. Factorial Program in C Using Pointers

Leave a Comment