I just started my first c++ class and we recieved our first assignment.

I dont have a compiler at home and live far away from school.

I have 2 questions:

These are the program requirements:

Program 1:

Prompt the user and let them enter three integers. Store them in three variables. Print the numbers in sorted order, from smallest to largest.

Sample run: (user input underlined)

Input integer 1 : 34

Input integer 2 : 200

Input integer 3 : -14

Sorted : -14 <= 34 <= 200

This is the code:

```
#include <iostream>
int main ( )
{
int one, two, three, first, sec, third;
cout << "Enter 3 integers./n";
cout << "Input Integer 1 : ";
cin >> one;
cout << "/nInput Integer 2 : ";
cin >> two;
cout << "/nInput Integer 3 : ";
cin >> three;
if ( one >= two && one >= three)
one == first;
if ( two >= one && two >= three)
two == first;
if ( three >= one && three >= two)
three = first;
if (one <= two && one >= three)
one == sec;
if (one >= two && one <= three)
one == sec;
if (two <= one && two >= three)
two == sec;
if (two >= one && two <= three)
two == sec;
if (three <= two && three >= one)
three == sec;
if (three >= two && three <= one)
three == sec;
if (one <= two && one <= three)
one = third;
if (two <= one && two <= three)
two = third;
if (three <= one && three <= two)
three = third;
cout << first << ">=" << sec << ">=" << third << ".";
cout << "Have a Nice Day!";
}
```

Will it work? Any changes(Im sure there is another way without all those ifs.

Program 2 requirments:

Prompt the user to type an integer in the range 0 - 1000. Allow the user to input an integer (you may assume correct type of input. Whenever the integer is not in the specified range, print an error message and make the user re-enter. Once a valid input is received, compute and print out the sum of the digits of the number.

Sample run 1: (user input underlined)

Please input an integer between 0 and 1000: 1001

* Number not in 0-1000 range. Please re-enter: -1

* Number not in 0-1000 range. Please re-enter: 456

Sum of the digits is 15

Code:

```
#include <iostream>
int main( )
{
int;
cout << "Enter an integer between and including 0-1000./n";
cin >> num;
if (num < 0 || num > 1000)
{
cout << "Number not between 0-1000./n";
cout << "Enter an integer between and including 0-1000./n";
cin >> num;
}
num1 = num / 100
num2 = (num % 100) / 100
num3 = (num % 100) % 10
cout << The sum of the digits is : ;
cout << num1 + num2 + num3
}
```

Thanks for any help you can provide, email me at rymade@yahoo.com

*Edited 3 Years Ago by Dani*: Formatting fixed