Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Pogram, If a pseudocode could be also provided I would really apreciate it.

ID: 3714502 • Letter: C

Question

C++ Pogram, If a pseudocode could be also provided I would really apreciate it.
Please create a menu-driven program that offers the user a chance to play with a list of numbers:

The Numbers List Game

1. Add one number to the end of the list

2. Display the list

3. Display the list backwards

4. Display the sum of all the numbers in the list

5. Exit the Numbers List Game

Here are the rules:

General Rules:

When the program starts, the list is empty.

Keep the menu looping around until the user wishes to stop.

Menu Option 1:

All numbers must be positive integers.

Allow no more than 20 numbers to be added to the list in any given run of the program. Don't allow the program to crash - keep a counter.

Menu Option 2:

Display the list. Either put a space between each number or put one number per line so that it's easy to read. Make all of the output beautiful.

Menu Option 3:

Display the list backwards. Either put a space between each number or put one number per line so that it's easy to read. Make all of the output beautiful.

Menu Option 4:

Add up all the numbers in the list and display that number.

Programming Rules:

You must use an array to hold the list of numbers. That array must be declared in main() and then passed around to the various functions.

Your code must be divided into logical functions - use a separate function to implement each menu option.

No global variables. Global constants are okay.

All good programming practices should be in place.

Explanation / Answer

Program:

// PROGRAM TO IMPLIMENT LIST

#include<iostream>

using namespace std; //header file declaration

void insert(int a[],int i) //insert function

{

int ele;

cout<<"enter eleemnt to be insert";

cin>>ele;

a[i]=ele;

}

void display(int a[],int c) //display function

{

int i;

for(i=0;i<c;i++) //for loop to visit all the locations

cout<<" "<<a[i];

cout<<" ";

}

void dispback(int a[],int c) //display in backward

{

int i;

for(i=c-1;i>=0;i--)

cout<<" "<<a[i];

cout<<" ";

}

int addition(int a[], int c) //addtion of all the elements in the list

{

int sum=0;

for(int i=0;i<c;i++)

{

sum+=a[i];

}

return sum; //return sum value

}

int main() //main program

{

int arr[20],count=0,ch; //variable declaration

do

{

//display the menu

cout<<"MENU "<<"1. INSERT "<<"2. Display "<<"3. PROCESS BACK WARD "<<"4. ADDITION "<<"5.EXIT ";

cout<<"enter 1 choice from the above menu ";

cin>>ch; //select your choice

switch(ch)

{

case 1: //case to impliment insert eleemnts with proper condtion

if(count==0) //check for first element

{

insert(arr,0);

count++;

}

else //check for overflow condtion

if(count==20)

cout<<"it is not possible to insert it if full ";

else

{

insert(arr,count);

count++;

}

  

break;

case 2:

cout<<"Given list is "; //display the content

display(arr,count);

break;

case 3: cout<<"Given list in reverse order is ";

dispback(arr,count);

break;

case 4: cout<<"Sum of all the numbers are :"<<addition(arr,count)<<" "; //sum of all the locations

break;

}

}while(ch!=5); //exit from the proram

}

Output:

MENU
1. INSERT
2. Display
3. PROCESS BACK WARD
4. ADDITION
5.EXIT
enter 1 choice from the above menu
1
enter eleemnt to be insert11
MENU
1. INSERT
2. Display
3. PROCESS BACK WARD
4. ADDITION
5.EXIT
enter 1 choice from the above menu
1
enter eleemnt to be insert12
MENU
1. INSERT
2. Display
3. PROCESS BACK WARD
4. ADDITION
5.EXIT
enter 1 choice from the above menu
1
enter eleemnt to be insert13
MENU
1. INSERT
2. Display
3. PROCESS BACK WARD
4. ADDITION
5.EXIT
enter 1 choice from the above menu
1
enter eleemnt to be insert14
MENU
1. INSERT
2. Display
3. PROCESS BACK WARD
4. ADDITION
5.EXIT
enter 1 choice from the above menu
2
Given list is
11 12 13 14
MENU
1. INSERT
2. Display
3. PROCESS BACK WARD
4. ADDITION
5.EXIT
enter 1 choice from the above menu
3
Given list in reverse order is
14 13 12 11
MENU
1. INSERT
2. Display
3. PROCESS BACK WARD
4. ADDITION
5.EXIT
enter 1 choice from the above menu
4
Sum of all the numbers are :50
MENU
1. INSERT
2. Display
3. PROCESS BACK WARD
4. ADDITION
5.EXIT
enter 1 choice from the above menu
5

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote