Hey guys i'm working with this code but i can't get it to stop looping back into the menu any ideas??? Thanks !!
#include <iostream>
using namespace std;
unsigned int menu();
int main() {
int i,num[20],sec[20],j,choice;
cout<< "Please enter 20 integers";
for (i=0; i<20; i++) {
cout<<"\nEnter next value:";
cin>>num[i]; }
for (;;) {
switch (menu()) {
case 0:
return 0;
case 1:{
cout<< num[i];
}
break;
case 2:
//some function to sort
break;
case 3:
//some function to show array
break;
case 4:
//some function to show adress of 1st el.
break;
}
}
return 0;
}
unsigned int menu() {
unsigned int c = -1;
while (c > 4) {
cout <<"<0> Exit\n"
"<1> Display their input\n"
"<2> Sort the array\n"
"<3> Show the sorted array\n"
"<4> Show the address of the first element\n";
cin >> c;
if (c > 4) {
cout << "Try again\n";
}
}
return c;
}