Menu Program with functions

I have a program that displays a menu and the user can choose options. However, I need to change the if statements into functions. The functions should be named fillVector , clearVector, printVector , reverseVector ,removeVector, the same as the menu option names.
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  #include <iostream>
#include <vector>
using namespace std;
int main()
{
    vector <int> fillVector;
    int input=0;
    int theCurrInt=0;
    int index =0;
    do{
        cout<<"1. fillVector \n2. clearVector \n3. printVector \n4. reverseVector \n5. removeVector \n6. quit " << endl;
        cin>> input;
        if(input==1){
            cout <<"Enter +ve values separated by spaces and a -ve value to indicate no more " << endl;
            while ( cin>> theCurrInt && theCurrInt>0 )
            {
                fillVector.push_back(theCurrInt) ;
            }
        }
        if(input==2){
            fillVector.clear();
        }
        
        if(input==3){
            for (int i=0; i<fillVector.size(); i++)
                cout<<fillVector.at(i)<<" ";
            cout << endl;
            
            
        }
        if(input==4){
            for (int i=fillVector.size(); i>0; i--)
                cout<<fillVector[i-1]<<" ";
            cout << endl;
            
        }
        if(input==5){
            int value;
            int count=0;
            cout << "Enter value to remove" << endl;
            cin >> value;
            for (int i=0; i<fillVector.size(); i++){
            
                    if(fillVector.at(i)==value)
                    {
                        for(int j=i; j<fillVector.size()-1; j++)
                        {
                            fillVector[j]=fillVector[j+1];
                        }
                        count ++;
                        break;
                    }
                index = i;
                }
            if(count==0)
            {
                cout<<value <<" not found..!!";
            }
            else{
                cout << value << " found at index " << index+1 << " removed" << endl;
        }
        }
}while(input!=6); cout <<"Good by!" << endl;
    return 0;}
Sounds like a good idea. Your if statements will be much more readable when you have only a function call inside. If you are not sure how to create functions have a look here:
https://www.tutorialspoint.com/cplusplus/cpp_functions.htm
Topic archived. No new replies allowed.