Greatest to Smallest Numbers

I need to write a program that asks the user to enter 10 numbers. It should then print out the biggest number and the smallest number.The program can use if statements, but should not use loops or arrays. It's for a class, so if you could walk me through it, that would be greatly appreciated.
Why don't you write a prototype, then post it here? Nobody here will do your work, and sounds like it could be for a programming class.
My solution basically consisted of having the user input ten numbers, and at the beginning of the program, I had them written out.

cout << "Enter a number: "
cin >> a;
cout << "Enter another number: "
cin >> b;
...
cout << "Enter another number: "
cin >> i;

Then I compared it to the other numbers:

if ((a > b) && (a > c) ... && (a > i))
print a;
else if ((b > a) && (b > c) ... && (b > i)
print b;
...
else if (i > a) && (i > b) ... & (i > h)
print i;
It seems silly your teacher doesn't want you to use loops because it just lengthens the code. Quite honestly you are meant to post topics once you try it yourself and still can't figure it out. Don't expect people to write code for you or most of the time you won't get any helpful responses.

Here's a basic idea though to get you started:

Create variables max and minimum. After you read in your first number assign max and minimum the first number. From there on read a number and check to see if it's bigger than your max or less than your minimum number and assign max/min to that new number if it is.
Well, loops could really help, but let's forget about that for now. (P.S., you would need to go to 'j' when going through the alphabet for your variables)

So, prints out the biggest and smallest, but not all of the others in order? If so, you could continue that pattern to find the largest, then switch from > to < to get the smallest. Also, you don't need to have the individual expressions in the if statements in parentheses. The && separates them. You can also have the user input 10 numbers by having something like cin>>a>>b>>c...>>i;
Thanks for the help!
Topic archived. No new replies allowed.