Sunday, 09.08.2020, 20:18
Welcome Guest | RSS
Site menu
Login form
Section categories
Search
Calendar
«  June 2011  »
SuMoTuWeThFrSa
   1234
567891011
12131415161718
19202122232425
2627282930
Entries archive
Our poll
Rate my site
Total of answers: 6
Statistics

Total online: 1
Guests: 1
Users: 0
Main » 2011 » June » 10 » Max, Min, Sum, Avg
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;
}

Category: C++ programs | Views: 394 | Added by: H_Imirzyan | Tags: min, average, maximum, minimum, Avg, Max, Sum | Rating: 0.0/0
Total comments: 0
Name *:
Email *:
Code *: