Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how to find the maximum of 10 numbers ?

Answer Posted / ahmed.aboelella

/**
As there is no need to save in array
Also we have to init max with first value to get max in case
user entered negative values
*/

#include "iostream"

using namespace std;

void main()
{
cout<<"Enter 10 numbers: ";

int i, temp, max;

//Enter first number to init max
cin>>max;

for(i = 0 ; i < 9; i ++)
{
cout<<"Enter Number: ";
cin>>temp;
max = temp > max ? temp : max;
}

cout<<"Max Number is "<<max<<endl;

}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a pdb file?

945


What is meant by the term name mangling in c++?

916


Explain the difference between using macro and inline functions?

1068


Explain queue. How it can be implemented?

1114


What is the basic structure of a c++ program?

1091


Is it possible to pass an object of the same class in place of object reference to the copy constructor?

985


Explain the advantages of using friend classes.

1097


Differentiate between an array and a list?

1148


Define the process of handling in case of destructor failure?

1006


What does the following code do: int c=0; cout< a) Undefined *Updated* b) 01 c) 00

1020


Which programming language is best?

942


Can we use this pointer inside static member function?

1029


What is the importance of mutable keyword?

991


what is VOID?

1019


What are the various storage classes in C++?

1101