Wednesday, October 19, 2011

Program: To calculate average of 3 numbers using function in c++




Calculate average of numbers using function

#include<iostream.h>
#include<conio.h>

int average(int,int,int)  ;
void main()
{
int a,b,c,d;
cout<<"Enter 3 numbers : "<<endl;
cin>>a>>b>>c;
d=average(a,b,c);
cout<<endl<<"Average is : "<<d;
getch();
}
int average(int x, int y, int z)
{
int s;
s=(x+y+z)/3;
return s;
}

Article by
Chief-Editor

He is a tech Enthusiast, an Altruist and calm mentor. He loves to code. He is also a creative graphic designer. Do check out his designfolio @ Jasmeet.asia If you like This post, you can follow me on Twitter.



For Further Reading,
C++ Program

0 comments:

Post a Comment