Write a C program to perform the following tasks In main inp

Write a C program to perform the following tasks: In main input three integers and call a function to calculate the sum of them using call-by-reference in function calculate and return sum of three integers

Solution

#include <stdio.h> // standard input output
int sumThree(int, int, int);// method declaration
int main(){
   int i,j,k;// declaring variables
   printf(\"Enter Integer-1:\");
   scanf(\"%d\",&i);// storing input value into i
   printf(\"Enter Integer-2:\");
   scanf(\"%d\",&j);
   printf(\"Enter Integer-3:\");
   scanf(\"%d\",&k);
   // calling method by reference and returning value
   printf(\"Sum of Three Integers is %d\",sumThree(i,j,k));
   getchar();
   return 0;
}
// here method goes for sumThree
int sumThree(int a, int b, int c){
   int sum=0;
   sum=a+b+c; // adding a b c to sum
   return sum;
}

 Write a C program to perform the following tasks: In main input three integers and call a function to calculate the sum of them using call-by-reference in func

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site