Sunday, 18 September 2016

DS-LAB(EXP-1) greatest of 3 no.

#include <iostream>
using namespace std;

int main() {
    
    float n1, n2, n3;
    cout << "Enter three numbers: ";
    cin >> n1 >> n2 >> n3;
    if(n1>=n2 && n1>=n3) {
        cout << "Largest number: " << n1;
    }
    if(n2>=n1 && n2>=n3) {
        cout << "Largest number: " << n2;
    }
    if(n3>=n1 && n3>=n2) {
        cout << "Largest number: " << n3;
    }


    return 0;
}
ALGO
Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: If a>b
           If a>c
              Display a is the largest number.
           Else
              Display c is the largest number.
        Else
           If b>c
              Display b is the largest number.
           Else
              Display c is the greatest number.  
Step 5: Stop
FLOWCHART

No comments:

Post a Comment