Hello,
for my assignment we need to create a code that generates
1. n number of random numbers (from 0-100) and store them in an array
2. then we have to ask the user a question if they want to see the numbers in the array
3. then ask the user if they want to see the numbers in the array in order from 0-100
4. then ask the user if they want to see the histogram of the data set
5. finally, ask the user if they want to see the number of data in the array, the max, the min, the standard deviation, average, variance.
I am however, finding it hard for the program to display the numbers of the array if the user says 'y' the question (AKA step 2)
Any help is great
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <iostream>
#include <time.h>
#include <cstdlib>
#include <stdlib.h>
using namespace std;
int main()
{
int numb=0;
int *newar=NULL;
char response;
cout << "enter integer:";
cin >> numb;
newar = new int [numb];
for(int i=0;i<numb;i++)
{
newar[i]=rand() % 101;
cout << "Do you want to see array? (Y/N) :";
cin>> response;
if (response != 'n')
{
cout<<newar[i]<<" ";
}
}
return 0;
}
|