17:57 Max, Min, Sum, Avg | |
#include <iostream> using namespace std; #define arg dbl a,dbl b,dbl c #define dbl double dbl max1(arg){ a=(a>b ? (a>c ? a:c) : (b>c ? b : c)); return a; } dbl min1(arg){ a=(a<b ? (a<c ? a : c) :(b<c ? b : c)); return a; } dbl sum1(arg){ return a+b+c; } dbl average1(arg){ return (a+b+c)/3; } int main(){ dbl x,y,z,m,s,d,e; cout<<"please enter the first value"<<endl; cin>>x; cout<<"please enter the second value"<<endl; cin>>y; cout<<"please enter the third value"<<endl; cin>>z; s=sum1(x,y,z); m=average1(x,y,z); d=max1(x,y,z); e=min1(x,y,z); cout<<endl<<" the maximum number is "<<d<<endl; cout<<" the minimum number is "<<e<<endl; cout<<" the sum of the numbers is "<<s<<endl; cout<<" the average value is "<<m<<endl;cin.get(); return 0; } | |
|
Total comments: 0 | |