Arrays

Hi, guys I needed some help with this program I was told that in order to do the standard deviation I should put my grades in an array so I was wondering is there anyway that I can put the grades that the user inputs in Choice = 1 into Choice = 3 is there anyway to convert them into an array basically I only wanna use the array in Choice = 3 can someone guide me the to the right path Thanks =)

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273`` ``````#include #include using namespace std; void Display_Menu(); int main () { Display_Menu(); int choice,grad,count,sum; int min = 100; int max = 0; int average,diff; cin >> choice; while (choice != 'q') { if (choice == 1) { while (grad >= 0) { cout <<"Enter the necessary grades.\n"; cin >>grad; if (grad >=0) { sum = sum + grad; count++; } if (grad 0) { min = grad; } if (grad > max) { max = grad; } } cout <<"Enter you're next choice.\n"; cin >> choice; } if (choice == 2) { average = sum/count; cout << "This is the average of the grades entered.\n" << average << "\n"; cout << "Select you're next choice.\n"; cin >> choice; } if (choice == 3) { } if (choice == 4) { cout << "This is the highest grade you entered.\n" << max << "\n"; cout << "This is the lowest grade you entered.\n" << min << "\n"; } cout << "Goodbye see you next time.\n"; break; } system ("pause"); return 0; } void Display_Menu() { cout << " Option 1 : Enter grades ( Quit with a negative value)\n"; cout << " Option 2 : Display the Mean(average) for the grades\n"; cout << " Option 3 : Display the standard deviation for the grades\n"; cout << " Option 4 : Display the high and low grades\n"; cout << " Option 5 : Enter 'q' to quit\n"; cout << "Enter you're choice (1-5)\n";``````
array can be only created if you know its size. otherwise you have to use dynamic array
below is the example for creating an dynamic array using pointers

 ``123456789101112131415161718192021222324252627282930313233343536373839404142`` `````` #include using namespace std; int *get(int size); int main() { int *pi; int size; cout<<"Enter the length of an array: "; cin>>size; cout<>list[i]; cout<
Topic archived. No new replies allowed.