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..

Dave Sinkula commented: Use code tags. +0

Recommended Answers

All 2 Replies

#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.

thanx narue really appriciated..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.