/* functions in C write a function that has two integer parameters and returns their sum test function in the loop, in the printf statement, and for calculating an average */ #include int sum(int a, int b); //function prototype int sum(int, int); int main(){ int i,n1, n2, func_result; //calling function in the loop //we will read 5 pairs (n1, n2) and find their sum printf("enter 5 pairs of integers\n"); for(i=0;i<5;i++){ scanf("%d%d",&n1,&n2); func_result=sum(n1,n2); printf("%d + %d = %d\n", n1, n2, func_result); } //calling function in printf statement printf("enter 2 integeres\n"); scanf("%d%d",&n1,&n2); printf("%d + %d = %d\n",n1,n2,sum(n1,n2)); //calculating average of two numbers printf("average of %d and %d is %f\n",n1,n2,(float)(sum(n1,n2))/2); return 0; } //function definition int sum(int a, int b){ return (a+b); /* int result=a+b; return result; */ }