0

I am a new C++ user with emacs. Our Prof. wanted us to create a prog. which basically write the positive which is entering ascending order.

I can do the ascending order program but he wanted us to make user prompt to enter the number in ascending order. The user also cant enter more then 10 numbers.

Please give me some hint and help me how to compile @ emacs.

Thank you...

3
Contributors
2
Replies
4
Views
8 Years
Discussion Span
Last Post by firstPerson
0

Hint
Declare an array of size 10. Use loop (for/while/do while) statement to read 10 values into an array.

How to compile?
type following command at the *nix prompt,

g++ -o outsort sort.cpp

Note: g++ to name the executable outsort (emacs)

0

make user prompt to enter the number in ascending order

Its limited to only positive numbers though. (not tested)

int lastNum = -1;
int newNum = 0;
int numEntered = 0;

while(numEntered != 10)
{
     cout<<"Enter  numbers in ascending order : ";
     cin >> newNum;
     while(newNum < lastNum)
   {
      cout<<"Enter a number greater than << lastNum<<" : ";
      cin >>  newNum;
   }
 numEntered ++;
  lastNum = newNum;
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.