Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include lbyec2a.h int get_choice(void) { /* This functions displays the menu. It also asks for a choice from the user. Then it would be

#include #include "lbyec2a.h"

int get_choice(void) { /* This functions displays the menu. It also asks for a choice from the user. Then it would be returned as an output Input: None Returns: choice (int) = Whatever choice the user entered in the console */ int choice = 0; printf("Menu: "); printf("1. Display the numbers "); printf("2. Display it in reverse order "); printf("3. Display values of even indices "); printf("4. Display values of odd indices "); printf("5. Rotate array by k (Forward) "); printf("6. Rotate array by k (Backward) ");

printf("choice: "); scanf("%d", &choice); return choice; }

void process_array(int array[], int size) { /* Process Array function would be a placeholder function to process the input based on the given problem. In this exercise, this function would like to use get_choice to get an input from the user. Afterwards, it would perform some processing depending on the input. The type of processing is as follows: 1 = just display the original (using display_original function) 2 = display its reverse (using display_reverse function) 3 = display values of even indices (using display_even function) 4 = display values of odd indicies (using display_odd function) 5 = display values from k to k-1 (using display_k function)

Input: array[] (int) = the array to be processed size (int) = the size of the array to be processed Returns: None */ int choice = get_choice(); if (choice == 1) { display_original(array, size); } else if (choice == 2) { display_reverse(array, size); } else if (choice == 3) { display_even(array, size); } else if (choice == 4) { display_odd(array, size); } else if (choice == 5) { rotate_forward(array, size); } else if (choice == 6) { rotate_backward(array, size); } }

int main(void) {

int num_array[10];

get_numbers(10, num_array);

process_array(num_array, 10);

return 0; }

Create a Program that asks for 10 integers (Use Arrays). Afterwards, display a navigation menu and perform the following: (1) Display the numbers

(2) Display it in reverse order

(3) Display the values of even indices (0th, 2nd, 4th, 6th, 8th, , 2n)

(4) Display the values of odd indices (1st, 3rd, 5th, 7th, 9th,.., 2n+1)

(5) Ask for an index k, then rotate array to the right.

(6) Ask for an index k, then rotate the array to the left.

Sample Input Expected Output
10 45 15 26 35 25 7 12 8 3 1 number: 10 45 15 26 35 25 7 12 8 3 Menu: 1. Display the numbers 2. Display it in reverse order 3. Display values of even indices 4. Display values of odd indices 5. Rotate array by k (Forward) 6. Rotate array by k (Backward) choice: 1 10 45 15 26 35 25 7 12 8 3
10 45 15 26 35 25 7 12 8 3 2 number: 10 45 15 26 35 25 7 12 8 3 Menu: 1. Display the numbers 2. Display it in reverse order 3. Display values of even indices 4. Display values of odd indices 5. Rotate array by k (Forward) 6. Rotate array by k (Backward) choice: 2 3 8 12 7 25 35 26 15 45 10
10 45 15 26 35 25 7 12 8 3 3 number: 10 45 15 26 35 25 7 12 8 3 Menu: 1. Display the numbers 2. Display it in reverse order 3. Display values of even indices 4. Display values of odd indices 5. Rotate array by k (Forward) 6. Rotate array by k (Backward) choice: 3 10 15 35 7 8
10 45 15 26 35 25 7 12 8 3 4 number: 10 45 15 26 35 25 7 12 8 3 Menu: 1. Display the numbers 2. Display it in reverse order 3. Display values of even indices 4. Display values of odd indices 5. Rotate array by k (Forward) 6. Rotate array by k (Backward) choice: 4 45 26 25 12 3
10 45 15 26 35 25 7 12 8 3 5 2 number: 10 45 15 26 35 25 7 12 8 3 Menu: 1. Display the numbers 2. Display it in reverse order 3. Display values of even indices 4. Display values of odd indices 5. Rotate array by k (Forward) 6. Rotate array by k (Backward) choice: 5 offset: 2 8 3 10 45 15 26 35 25 7 12
10 45 15 26 35 25 7 12 8 3 6 2 number: 10 45 15 26 35 25 7 12 8 3 Menu: 1. Display the numbers 2. Display it in reverse order 3. Display values of even indices 4. Display values of odd indices 5. Rotate array by k (Forward) 6. Rotate array by k (Backward) choice: 6 offset: 2 15 26 35 25 7 12 8 3 10 45

Testing Guidelines:

Assume that the length of the input would be exactly 10 all the time

Assume that inputs are integers all the time.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions