C Write the C code for a function that receives two integers

C++

Write the C++ code for a function that receives two integers passed to it. The function, named average, should return the average of the two numbers.

Solution

#include<iostream.h>

#include<conio.h>

int average(int,int) ;

void main()

{

int a,b,c;

cout<<\"Enter 2 numbers : \"<<endl;

cin>>a>>b;

c=average(a,b);

cout<<endl<<\"Average is : \"<<c;

getch();

}

int average(int x, int y)

{

int s;

s=(x+y)/2;

return s;

}

C++ Write the C++ code for a function that receives two integers passed to it. The function, named average, should return the average of the two numbers.Solutio

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site