(Homework Solution): Year-Goop x 5 Part 2- GooglexMicrosoft Word-ch le.php/12344 9/ch6-1 Jab_array_single.pdf

Year-Goop x 5 Part 2- GooglexMicrosoft Word-ch le.php/12344 9/ch6-1 Jab_array_single.pdf (array.cpp) You are going to make a program with an array of integer values. You will create 2 operations on the array for this lab (and 6 more for assignment 6) and call each operation from a switch using a do-while loop. 1. main function Declare a const for the size of the array inside the main (dont make it global). Use 5 for the size of the array Create an array with SIZE. Compile your program now Make sure it compiles before you move onto 2 2. fillArray function Fill the array with numbers entered from the keyboard. Check page 10 in Lecture Notes 6-1: arrays on CC Call fillArray in the main function. Compile & Run your program now Make sure it runs perfectly (the user gets to enter 5 numbers) before you move onto #3. 3. printArray function. Output the contents of the array as shown below → Check page 10 in Lecture Notes 6-1 : arrays on CC Dont forget to use const if you are not changing the array in a function. void printArraycons int all, ????) Sample run The numbers in the array are 20 16 32 80 10 Call printArray in the main function. Compile & Run your program now Make sure it runs perfectly (the user gets to enter 5 numbers and those 5 numbers should be shown in the same format as the above sample run) before you move onto 4
media%2Ff8c%2Ff8c0819d-6293-4e20-8379-de
media%2F07b%2F07bb6f87-4e70-4636-aed6-20
media%2Fcf6%2Fcf62785f-5e73-40fb-be42-61

Year-Goop x 5 Part 2- GooglexMicrosoft Word-ch le.php/12344 9/ch6-1 Jab_array_single.pdf (array.cpp) You are going to make a program with an array of integer values. You will create 2 operations on the array for this lab (and 6 more for assignment 6) and call each operation from a switch using a do-while loop. 1. main function Declare a const for the size of the array inside the main (don’t make it global). Use 5 for the size of the array Create an array with SIZE. Compile your program now Make sure it compiles before you move onto 2 2. fillArray function Fill the array with numbers entered from the keyboard. Check page 10 in “Lecture Notes 6-1: arrays” on CC Call fillArray in the main function. Compile & Run your program now Make sure it runs perfectly (the user gets to enter 5 numbers) before you move onto #3. 3. printArray function. Output the contents of the array as shown below → Check page 10 in “Lecture Notes 6-1 : arrays” on CC Don’t forget to use const if you are not changing the array in a function. void printArraycons int all, ????) Sample run The numbers in the array are 20 16 32 80 10 Call printArray in the main function. Compile & Run your program now Make sure it runs perfectly (the user gets to enter 5 numbers and those 5 numbers should be shown in the same format as the above sample run) before you move onto 4

Expert Answer

answers

//Please find the below code :

#include <iostream>

using namespace std;

void fillArray(int arr[],int size); //for filling contents of array from user

void printArray(const int arr[],int size); //for printing the contents of array

void reverseArray(int arr[],int size); //for reversing the contents of array

int main() {

const int size = 5; //define a const for array size

int arr [size];

int choice;

 

do{

 

cout<<“n======================================”;

cout<<“nMenu”;

cout<<“n1. Fill Array”;

cout<<“n2. Print Array”;

cout<<“n3. Reverse contents of array”;

cout<<“n10. Quit”;

cout<<“n======================================”;

cout<<“nEnter your choice : “;

cin>>choice;

 

switch(choice) //begin switch-case for choice validation

{

case 1 :fillArray(arr,size);

break;

case 2 :printArray(arr,size);

break;

case 3 :reverseArray(arr,size);

break;

case 10:cout<<“”;

break;

default:cout<<“Invalid choice”;

}

}while(choice!=10); //exit while loop only if user enters choice=10

cout<<“Thank you for using our system”;

 

}

void fillArray(int arr[],int size)

{

for(int i=0;i<size;i++) //loop to take in array values

{

cout<<“Enter a number : “;

cin>>arr[i];

}

}

void printArray(const int arr[],int size)

{

cout<<“nArray values are : “;

for(int i=0;i<size;i++) //loop to display the array

cout<<arr[i]<<“t”;

cout<<“n”;

}

void reverseArray(int arr[],int size)

{

cout<<“nReversed Array : “;

int i,j,k,temp;

for(i=0,j=size-1;i<size/2;i++,j–) //using two variables – (i)to start from beginning,(j)to start from end

{

temp=arr[i]; //temp variable used for swapping

arr[i]=arr[j];

arr[j]=temp;

}

for(k=0;k<size;k++) //loop to print the reversed array

cout<<arr[k]<<“t”;

}

/*Please find the below generated output for a run :

======================================

Menu

1. Fill Array

2. Print Array

3. Reverse contents of array

10. Quit

======================================

Enter your choice : 1

Enter a number : 56

Enter a number : -896

Enter a number : 78

Enter a number : 555

Enter a number : -986

======================================

Menu

1. Fill Array

2. Print Array

3. Reverse contents of array

10. Quit

======================================

Enter your choice : 2

Array values are : 56 -896 78 555 -986

======================================

Menu

1. Fill Array

2. Print Array

3. Reverse contents of array

10. Quit

======================================

Enter your choice : 3

Reversed Array : -986 555 78 -896 56

======================================

Menu

1. Fill Array

2. Print Array

3. Reverse contents of array

10. Quit

======================================

Enter your choice : 10

Thank you for using our system

*/

iWriteHomework
Order NOW for a 10% Discount
Pages (550 words)
Approximate price: -

Why Us?

Top Quality and Well-Researched Papers

All ourbpapers are written from scratch. In fact, Clients who ask for paraphrasing services are highly discouraged. We have writers ready to craft any paper from scratch and deliver quality ahead of time.

Professional and Experienced Academic Writers

Our writers keeps you posted on your papers progress - providing you with paper outline/draft. You are also at liberty to communicate directly with your writer.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time, in many cases quite ahead of time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents