NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

process a data set of random numeric information

 
Post new topic   Reply to topic    NetBeans Forums -> C/C++ Users
View previous topic :: View next topic  
Author Message
lizzie1441



Joined: 23 Mar 2017
Posts: 1

PostPosted: Thu Mar 23, 2017 4:53 am    Post subject: process a data set of random numeric information Reply with quote

It should start by creating an array that can hold a maximum of 100 double or float elements. There should also be at least one integer that will hold the number of values that are placed into the array.

In the program, I need the functions:

Code:

    double randDouble();
    int buildArray( double array[]);
    void printArray( double array[], int numberOfValues);
    void sortArray( double array[], int numberOfValues);




Call the buildArray function to fill the array with a random number of random values. The value that is returned from the function should be displayed in the integer variable.

Display the number of values that were placed in the array with an appropriate label.

Display a simple title such as "Unsorted Numbers" and then call the printArray function that is described below to display the array of unsorted values.

Call the sortArray function that is described below to put the values in the array in ascending order.

Finally, display a title for the sorted data and then call the printArray function a second time to display the sorted values.

Also, I only want the float or double to only have 4 decimal places after. i.e. 0.1234

javascript:emoticon('Question')

I am really struggling with this assignment and I was wondering if someone can help explain what I need to do. I don't have much but this is what I have so far

Code:
   
    #include <iostream>
    #include <iomanip>
    #include <ctime>
    #include <cstdlib>

    using namespace std;


    int main(int argc, char *argv[])
   
    {
    srand((unsigned int)time(0));
   
        double a = 100.0;
        for (int i = 0; i <= 100.0; i++)
            printf("%f\n", ((double)rand()/(double)(RAND_MAX)) * a);
        return 0;
    }


The output should look like:

Number of values: 58

Unsorted Numbers
23.5572 64.8152 7.4374 27.0241 36.0027 25.5287 98.5290
31.8918 93.4233 17.8625 85.7570 3.4852 0.8576 62.6759
48.5885 27.2988 80.2179 9.1464 44.8012 64.0156 97.3266
66.0878 79.0613 56.3280 4.0376 88.1405 6.8361 29.6793
98.5076 7.4648 1.8006 2.5636 56.7248 51.5976 64.8122
72.0573 38.5052 38.0139 2.6460 90.1303 20.9906 86.1324
54.5885 96.4293 62.8193 37.2692 94.9461 23.1269 52.0829
23.2826 89.7366 37.4737 41.2152 74.4285 35.5510 37.6263
21.9001 7.1139

Sorted Numbers
0.8576 1.8006 2.5636 2.6460 3.4852 4.0376 6.8361
7.1139 7.4374 7.4648 9.1464 17.8625 20.9906 21.9001
23.1269 23.2826 23.5572 25.5287 27.0241 27.2988 29.6793
31.8918 35.5510 36.0027 37.2692 37.4737 37.6263 38.0139
38.5052 41.2152 44.8012 48.5885 51.5976 52.0829 54.5885
56.3280 56.7248 62.6759 62.8193 64.0156 64.8122 64.8152
66.0878 72.0573 74.4285 79.0613 80.2179 85.7570 86.1324
88.1405 89.7366 90.1303 93.4233 94.9461 96.4293 97.3266
98.5076 98.5290 Question Question Question Question
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> C/C++ Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo