Thread: Array in ascending order and Average

  1. #1
    Registered User
    Join Date
    Mar 2014
    Posts
    20

    Array in ascending order and Average

    So this is my first time programming. I am getting the hang of it pretty well. I created a program that asks the user to input arrays. Now, I need to calculate the average of the inputted arrays, and I need to place them in order from low to high. I have been struggling with doing these two parts for a while now and now decided that the book is no help, I need some from some actual programmers. I attached my program. Look at it and help me. I have been doing so well up to this point and now I am just completely clueless. I appreciate it everyone who helps!!
    My program printed here!
    Code:
    #include
    <iostream>
    using
    namespace std; 
    int
     main()
    {
        
    int size = 10;
        
    int *pointer = NULL;
        cout << 
    "Number of expected times:" <<endl;
        
    int input;
        cin >> input;
     
        pointer = 
    newint[input];
        
    int temp;
     
        
    for( int counter = 0; counter < input ; counter ++){
            cout << 
    "Enter Expected Time:" <<counter + 1<<endl;
            cin >> userInput[1]; 
            *(pointer+counter) =  temp;
        }
        cout << 
    "The Expected Times are:"<<endl;
        
    for( int counter = 0; counter < input ; counter ++){
            cout <<counter +1 << 
    "Expected Time:" <<*(pointer+counter)<<endl;
            
        
        cout <<
    " The Average Expected Time is " << userInput[2] << endl;
        }
        
        
    delete [] pointer;
        
    return 0;
    }
    

  2. #2
    Registered User
    Join Date
    Mar 2014
    Posts
    20
    I know how to use a bubble sort, and I would like to use something different!

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Please format your code properly and post it within code tags without any other markup. This way, the forum software used here will maintain your indentation and insert syntax highlighting and line numbering.

    Next, what exactly are the problems that you are facing? How does your code not work?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Are you able to use the existing std::sort function from the <algorithm> header or is this something you must code yourself?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  5. #5
    Registered User
    Join Date
    Mar 2014
    Posts
    20
    I can use anything other than bubble sort. As long as it outputs the times and it averages them and puts them in order I am pretty much free to do what I want

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help printing array in ascending order in C programming?
    By celticpride in forum C Programming
    Replies: 5
    Last Post: 04-06-2011, 03:19 PM
  2. Sort an Array in Ascending Order ?
    By Coding in forum C++ Programming
    Replies: 5
    Last Post: 01-09-2008, 08:32 PM
  3. array in ascending order
    By galmca in forum C Programming
    Replies: 4
    Last Post: 10-25-2004, 11:44 AM
  4. printing array elements in ascending order
    By galmca in forum C Programming
    Replies: 29
    Last Post: 10-24-2004, 11:24 PM
  5. organize values of array in ascending order
    By incognito in forum C++ Programming
    Replies: 4
    Last Post: 11-08-2003, 10:55 PM

Tags for this Thread