# (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 (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

//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<<“n1. Fill Array”;

cout<<“n2. Print Array”;

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

cout<<“n10. Quit”;

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

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 :

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

1. Fill Array

2. Print Array

3. Reverse contents of array

10. Quit

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

Enter a number : 56

Enter a number : -896

Enter a number : 78

Enter a number : 555

Enter a number : -986

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

1. Fill Array

2. Print Array

3. Reverse contents of array

10. Quit

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

Array values are : 56 -896 78 555 -986

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

1. Fill Array

2. Print Array

3. Reverse contents of array

10. Quit

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

Reversed Array : -986 555 78 -896 56

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

1. Fill Array

2. Print Array

3. Reverse contents of array

10. Quit

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

Thank you for using our system

*/

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.

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.

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?

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

Proceed with the payment

Choose the payment system that suits you most.

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.

## 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.