Explanation::
- Debugged code in c++ is provided below.
- Wherever changes are made, comments are provided.
- Detailed explanation is given about changes and cause of logical errors.
- Please read all the comments for better understanding of the changes made in code.
Truth Table of AND and OR::
Note:: Need for truth table is provided in code comments. It is used to explain why do-while loop was not looping if user entered wrong input like choice=-1

Code in C++::
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int choice;
int amt;
do {
cout << “Make a choice from the following menu:” << endl;
cout << ” 1. Add a user” << endl;
cout << ” 2. Delete a user” << endl;
cout << ” 3. Modify a user” << endl;
cout << ” 4. View a user” << endl;
cout << ” 5. Contact a user” << endl;
cin >> choice;
/*
* Now to loop again and again if user enters wrong input then
* replace &&(AND) condition TO ||(OR) condition.
* For example suppose choice=-1 which is wrong,
* while() condition checks first choice<0 -> true
* but choice > 5 -> false . So if && is used then this
* while loop will be false and do-while loop gets
* terminated.
* See images of truth table provided in explanation section.
* So I have replaced && with ||.
* Now for OR at least one parameter has to be true.
* choice < 0 is true so while condition is also true.
*/
} while (choice < 0 || choice > 5);
/*
* switch cases need to have break statements for each of its cases.
* If there are no break statement then all the cases will be
* executed that are without break statement.
* So this is the big change done below.
*/
switch (choice) {
case 1:
cout << “You chose ‘add a user'” << endl;
break;
case 2:
cout << “You chose ‘delete a user'” << endl;
break;
case 3:
cout << “You chose ‘modify a user'” << endl;
break;
case 4:
cout << “You chose ‘view a user'” << endl;
break;
case 5:
cout << “How many users? “;
cin >> amt;
cout << “Enter users:” << endl;
/*
* In for loop initially it was scanning only one name.
* Because there was a semicolon at end of for loop statement as
* for(int i=0;i<=amt;i++);{}
* So i have removed that semicolon.
*/
/*
* Another change made is integer amt stores number of
* names to be taken as input.
* So for loop start with i=0 and suppose amt=5
* Then for loop has to run from i=0 to i=4(both inclusive)
* i.e 0<=i<amt
*/
for (int i = 0;i<amt;i++){
string name;
cin >> name;
cout << “Contacting ” << name << endl;
}
break;
default:
cout << “Unknown choice: ” << choice << endl;
break;
}//switch case ends here
return 0;
}
Output::
Test Case 1::

Test Case 2::
