Home TechnologyProgramming Subscribe to RSS
 

C++ Program Code That Ask The User To Enter 5 Numbers And Output The Largest And Smallest Number?

Answer Question

1 Answer - Sort by: Date | Rating

    Hi; Here is your Program. And it works well.
    #include<iostream.h>
    #include<conio.h>

    void main(){
    int Nums[4],i;
    cout<<"Enter Five Numbers:";
    for (i=0;i<5;i++){
    cin>>Nums[i];
    }


    int Greatest=0;
    int Smallest;


    for(i=0;i<5;i++){

    if(Greatest<Nums[i])
      Greatest=Nums[i];

    if(Smallest>Nums[i])
      Smallest=Nums[i];

    }

    cout<<"Smallest number is"<<Smallest;
    cout<<"Greatest number is"<<Greatest;

    getch();

    }
    0 0

    Alon_nad 

    answered 3 months ago

      Answer Question - Answers are editable for 5 min.

      If you do not Sign-in or Register your answers will be anonymous,

      your answers may also be checked before going online.

      More

         
         

        Ask a Question via Twitter

        Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

        Blurtit Store

        Get T-shirts, hoodies, caps and more at the Blurtit store

        Blurtit International