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 extraction and insertion operators in c++?

1004


Explain the difference between c++ and java.

1120


What is the this pointer?

1123


What is a base class?

1116


What is encapsulation in c++?

1299


how to access grid view row?

2242


Explain virtual class?

1037


What are friend classes? What are advantages of using friend classes?

1105


Write a Program to find the largest of 4 no using macros.

1083


Please explain class & object in c++?

1096


Describe the role of the c++ in the tradeoff of safety vs. Usability?

1218


Explain the difference between overloading and overriding?

1146


Explain the isa and hasa class relationships. How would you implement each?

1132


What are the differences between the function prototype and the function defi-nition?

1106


Do you know the problem with overriding functions?

1109