Close
Close

Prompt aprogram which takes three ages from user and print the youngest and oldest among them

   SONIA (F-Name : SHOUKAT ALI)


Answers

  •   
    #include<iostream>
    int main(){
        using namespace std;
    
        int age1, age2, age3;
        cout << "Enter age 1" << endl;
        cin >> age1;
        cout << "Enter age 2" << endl;
        cin >> age2;
        cout << "Enter age 3" << endl;
        cin >> age3;
    
        int youngest = age1;
        int oldest = age1;
        if(age2>oldest)
            oldest = age2;
        if(age2<youngest)
            youngest = age2;
        if(age3>oldest)
            oldest = age3;
        if(age3<youngest)
            youngest= age3;
    
        cout << "oldest "<< oldest << endl;
        cout << "youngest "<< youngest << endl;
    
        return 0;
    }
    

     



Ask Yours
Post Yours
Write your answer