Sum of Two Numbers using Functions
In this example code, you will learn to make sum of two numbers in c using function. Sum of two numbers is the basic program to add the values of two numbers and print addition as result in c language. for example:
a = 5, b = 10;
sum = a + b;
Example: Sum of two numbers in C using functions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include<stdio.h> int sum(int j,int k) { return(j+k); } int main() { int n1, n2; printf("\nEnter Two Numbers: "); scanf("%d%d",&n1,&n2); int res=sum(n1,n2); printf("\nSum = %d",res); return 0; } |
Output
Enter Two Numbers: 4
5
Sum = 9
Check out our other C programming Examples