C Program To Add Two Numbers using Function
Learn How To Add Two Numbers using Function in C Programming Language. This C Program To Calculate Sum of Two Numbers makes uses of Call By Value approach. The Call by Value approach is different from Call By Method approach. Call by Value method does not pass the address of the values stored. Instead, it passes the values of the variables. Therefore, the Original Values are not changed.
Note: This Code For Addition of Two Numbers in C Programming has been compiled with GNU GCC Compiler and developed with gEdit Editor and Terminal in Linux Ubuntu Operating System.
Add Two Numbers using Function in C Programming
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include<stdio.h> int add(int x, int y); int main() { int num1, num2, res; printf("\nAdd First Number:\t"); scanf("%d", &num1); printf("\nAdd Second Number:\t"); scanf("%d", &num2); res = add(num1, num2); printf("\nAddition of Two Numbers: %d", res); printf("\n"); return 0; } int add(int x, int y) { int sum; sum = x + y; return sum; } |
Output

If you have any doubts or Compilation Errors in this C Program For Calculating Sum of Two Integers using Function, mention it in the comment section.
wow i love it i never knew how to use functions very well. i use to use
let say i will say res = num1 + num2;
it the same think but know i will be able to user functions and also learn how to call a function thanks
You’re Welcome!! 🙂