Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

greatest and smallest in 3 numbers cpp

// greatest / smallest among three

#include <iostream>
using namespace std;

int main()
{
    int a, b, c, greatest , smallest;

    cout<< "Enter three numbers: ";
    cin>> a >> b >> c;

    if(a>b && a>c)
        greatest = a;

    else if(b>a && b>c)
        greatest = b;

    else
        greatest = c;

    if(a<b && a<c)
        smallest = a;

    else if(b<a && b<c)
        smallest = b;

    else
        smallest = c;

    cout << "Greatest = " << greatest <<endl;
    cout << "smallest = " << smallest;

    return 0;
}
 
PREVIOUS NEXT
Tagged: #greatest #smallest #numbers #cpp
ADD COMMENT
Topic
Name
7+4 =