Addition of two numbers in C
Addition Operation in C
C Languages providing multiple operators to do mathematical operations.The addition operator(+) helps to perform the addition of two numbers.There are two numbers which stored in a two separate variables.Example A=5,B=6.Similarly the output of the addition will get stored in another variable.Here the output variable is C.
Expression for Addition: c = a + b
Implementation
1 2 3 4 5 6 7 8 9 10 11 12 |
#include<stdio.h> int main() { int a,b,c; printf("Enter the number1: "); scanf("%d",&a); printf("Enter the number2: "); scanf("%d",&b); c = a+b; printf("The Addition of two numbers is: %d",c); return 0; } |
Output:

Add two numbers using function in C programming
The num1 and num2 values are passed as arguments to the function addition( ).The sum of two numbers is stored in the variable result and returns the value to the function from where it gets called.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#include<stdio.h> int main() { int num1,num2,sum; printf("Enter the number1: "); scanf("%d",&num1); printf("Enter the number2: "); scanf("%d",&num2); sum = addition(num1,num2); printf("The addition of two numbers is: %d",sum); return 0; } int addition(int a,int b) { int result = a + b; return result; } |
Output:
