-1

program that asks user to input 12 numbers of any type
or domain (i.e. positive or negative) and record user's responce into an
array.

Process the input by manipulating it so that the numbers are arranged in
the array in an ascending order (e.g. -1.2, -1, 0, 3, 4, 4.05, 4.1, 5).

After the manipulation is complete, print the resulting values in the
array in one line. i wrote it this much so far

#include <iostream>
using namespace std;
int main ()
{

float x;

int i;
for ( i = 0; i < 12; ++i )
{
cout << "Enter values #" << i + 1 << ": ";
cin >> x;
}
}


but i need help with array part and printing part..

Votes + Comments
Use code tags.
2
Contributors
2
Replies
3
Views
12 Years
Discussion Span
Last Post by bryan7890
0
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
  double list[12];

  cout<<"Enter 12 numbers: ";

  for ( int i = 0; i < 12; i++ )
    cin>> list[i];

  sort ( list, list + 12 );

  for ( int i = 0; i < 12; i++ )
    cout<< list[i] << ( i + 1 == 12 ? "" : ", " );
  cout<<endl;
}

Now you only need to worry about sorting the array because I'm sure your teacher won't accept the standard sort function.

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.