C++ Code To Find The Maximum And Minimum Among All The Entered Numbers.



C++ Code To  Find The Maximum And Minimum Of  All The Entered Numbers:
 ============================================================


#include <iostream>
#include <string.h>
#include <math.h>
#include<limits.h>
using namespace std;

int main()
{
    int any;
    cout<<"*********  Maximum and minimum ************"<<endl;
    cout<<"\nEnter 1 to Preceed or 0 to exit : "<<endl;
    cin>>any;
    if(any!=0)
    {
    do
        {
    int a=0,b=0,c=0,d=INT_MAX;

    do{
    cout <<"Enter the number"<<endl;
    cin>>a;
    b=max(b,a);
    c=min(a,d);
    if(a!=0){
    d=c;
    }
    }while(a!=0);

    cout<<"The maximum of entered value is : "<<b<<endl;
    cout<<"The minimum of entered value is : "<<d<<endl;
cout<<"\n======================================"<<endl;
            cout<<"\nEnter 1 to Preceed or 0 to exit : "<<endl;
            cin>>any;
            cout<<"\n";
        }
        while(any!=0);
    }
}

No comments:

Post a Comment