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 are the types of container classes?

1085


What is null c++?

1073


Is turbo c++ free?

1015


Explain the uses of static class data?

1053


What is the use of lambda in c++?

966


What is conditions when using boolean operators?

1141


Is it legal in c++ to overload operator++ so that it decrements a value in your class?

1007


What is the difference between passing by reference and passing a reference?

1023


How many types of comments are there in c++?

942


Name the operators that cannot be overloaded in C++?

1001


Explain queue. How it can be implemented?

1104


Why do we use templates?

990


Why c++ does not have finally?

1020


What is a float in c++?

931


How come you find out if a linked-list is a cycle or not?

988