Write a program to illustrate function call.
Answers
Answered by
0
The answer is in the attachment
Attachments:
Answered by
0
Write a program to illustrate function call.
Explanation:
C program to add two integer numbers.
#include <stdio.h>
int sum(int a, int b); // function prototype
int main()
{
int n1,n2,s;
printf("Enters two numbers: ");
scanf("%d %d",&n1,&n2);
s = sum(n1, n2); // function call with two parameters
printf("sum = %d",s);
return 0;
}
int sum(int a, int b) // function definition
{
int result;
result = a+b;
return result; // return statement
}
Output
Enters two numbers: 45
56
sum = 101
Note
In above program,function call is sum(n1, n2) where sum is function name and n1 and n2 are two parameters separated by commas and enclosed within parentheses.
Similar questions