#include <iostream>
#include <vector>
using namespace std;
void printing(vector<int> numbers);
char ask(char selection);
int main(){
vector<int> numbers{1,1,2};
char selection{};
ask(selection);
switch(selection) {
case 'P':
printing(numbers);
break;
case 'M':
cout << "FF" << endl;
break;
default :
cout << "error" << endl;
}
printing(numbers);
return 0;
}
char ask(char selection)
{
cout << "Enter the selection " << endl;
cout << "\nP - Print numbers" << endl;
cout << "A - Add a number" << endl;
cout << "M - Display mean of the numbers" << endl;
cout << "S - Display the smallest number" << endl;
cout << "L - Display the largest number"<< endl;
cout << "Q - Quit" << endl;
cout << "\nEnter your selection: ";
cin >> selection;
return selection;
}
void printing(vector<int> numbers){
if (numbers.size() == 0){
cout << "[] - the list is empty" << endl;
}
else{
cout << "[ " ;
for (auto num : numbers){ cout << num << " " ; }
cout << "] " << endl;
}
}
Here the switch
statement is not working, it's not printing the vector that I need.