help with this prog

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2004
Posts: 13
Reputation: bryan7890 is an unknown quantity at this point 
Solved Threads: 0
bryan7890 bryan7890 is offline Offline
Newbie Poster

help with this prog

 
-1
  #1
Nov 7th, 2004
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..
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,606
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 713
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: help with this prog

 
0
  #2
Nov 7th, 2004
  1. #include <algorithm>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. double list[12];
  9.  
  10. cout<<"Enter 12 numbers: ";
  11.  
  12. for ( int i = 0; i < 12; i++ )
  13. cin>> list[i];
  14.  
  15. sort ( list, list + 12 );
  16.  
  17. for ( int i = 0; i < 12; i++ )
  18. cout<< list[i] << ( i + 1 == 12 ? "" : ", " );
  19. cout<<endl;
  20. }
Now you only need to worry about sorting the array because I'm sure your teacher won't accept the standard sort function.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 13
Reputation: bryan7890 is an unknown quantity at this point 
Solved Threads: 0
bryan7890 bryan7890 is offline Offline
Newbie Poster

Re: help with this prog

 
0
  #3
Nov 7th, 2004
thanx narue really appriciated..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC