I started the two programs but am still unsure how to do the sum for the first one and how to sort the second one. I don't think we can use functions or strings because we haven't gotten that far in this class.

Here are the two programs that I wrote unfinished:

This one should read in a digit greater than0 but less than 1000. Then if the digit is valid, the sum of it should be calculated. I don't know how to do that part. Example: Enter a digit: 54

Sum is 9.

Code:

#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int integer;
cout << "Please input an integer between 0 and 1000: ";
cin >> integer;
cout << " Number not in 0-1000 range. Please re-enter: ";
while( integer >= 0 || integer <= 1000)
{
cout << "Please input an integer between 0 and 1000: ";
cin >> integer;
cout << " Number not in 0-1000 range. Please re-enter: << ";
}
return 0;
}

For this one, you have to put in three integers. Then, they have to be sorted from smallest to largest. example -9 < 98 <128. I don't know how to sort the numbers from largest to smallest. Can someone help me?

Code:

#include <iostream>
using std::cout;
using std::cin;
int main ()
{
int num1, num2, num3;
cout << "Enter integer 1 : ";
cin >> num1;
cout << "Enter integer 2 : ";
cin >> num2;
cout << "Enter integer 3 : " ;
cin >> num3;
return 0;
}