Simple MENU Program in C++

In this post, we are going to understand the Simple MENU Program in C++. We will use a switch statement to display the menu in C++ As you do in other GUI languages. We are using the switch statement in the Main() function and displayMenu() function with some custom functions inside it to display MENUS.

List of 5 Custom functions used in displaymenu() function

In this program code, we are using function the displaymenu() to display a MENU on Console. These are the 5 functions we are using to display different MENU as per user input. We can change the number of many MENUS as per need. First will user input the enter the choice based on User’s choice different Menu will display and these below functions will call.

  • void Addstudent() : To add a new student
  • void DeleteStudent() : To delete an existing student.
  • void updatestudent() : To update a student record.
  • void ViewAllStudentRecords() : To view records of all students,
  • void FindStudent() : To find a studnet by ID.

You may also like :

Simple Program to Display Menu in C++

This is full code to display MENU in C++

C++ Program to Display Menu

#Source Code to display Menu in C++

#include <iostream>
using namespace std;
//Code by
void displaymenu()
{ cout<<"===================================================== \n";
cout<<" \t\tMENU \t \n ";
cout<<"===================================================== \n";
cout<<" 1.Add student records\n";
cout<<" 2.Delete student records\n";
cout<<" 3.Update student records \n";
cout<<" 4.View all student records \n";
cout<<" 5.Find a student by ID \n";
}//Code by
void Addstudent()
cout<< "you have selected add student : \n";
void DeleteStudent()
cout<< "you have selected delete student \n";
void updatestudent()
cout<< "you have selected update student 3\n";
void ViewAllStudentRecords()
cout<< "View all student records 4\n";
void FindStudent()
cout<< "you have selected Find a stduent \n";

//Code by

int main()

string st[20];
int itemcount = 0;

#function to display Menu

int yourchoice;
string confirm;
{ cout<<"Enter your choice(1-5):";
switch (yourchoice)
case 1: Addstudent(); break;
case 2: DeleteStudent();break;
case 3: updatestudent(); break;
case 4: ViewAllStudentRecords(); break;
case 5: FindStudent();break;
default: cout<<"invalid"; break;
cout<<"Press y or Y to continue:";
} while (confirm == "y" || confirm == "Y");
return 0;




 1.Add student records

 2.Delete student records

 3.Update student records 

 4.View all student records 

 5.Find a student by ID 

Enter your choice(1-5):1

you have selected add student : 

Press y or Y to continue:^A

How does it works

Inside the Main() function we are using the switch statement to display the MENU as per user input.

We are asking users to enter the choice for MENU to display. As per user input Menu from 1 to 5 will select.

  • if user Input 1 then Addstudent menu will be select.
  • if user input 2 then DeleteStudent menu will be select.
  • if user Input 3 then updatestudent menu will be select.
  • if user input 4 then ViewAllStudentRecords menu will be select.
  • if user Input 5 then FindStudent menu will be select.

Then finally selected will display on the console.