Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Note: initialize arrays in all three tasks by random values. Ask user which task to execute and your code should keep running until user say

Note: initialize arrays in all three tasks by random values. Ask user which task to execute and your code should keep running until user say so. 1. Block swap algorithm for array rotation Write a function rotate(ar[], d, n) that rotates arr[] of size n by d elements. Rotation of the above array by 2 will make array. In your main function, Declare array of size 7. Initialize this array with random values. Display this array Ask user for number of elements to rotate d. Call the user defined function named rotate Display the array again. 2. k largest elements in an array Write C++ code for printing k largest elements in an array of size 50. Display the array after initialization and display k largest values in that array. For example, if given array is [1, 23, 12, 9, 30, 2, 50] and you are asked for the largest 3 elements i.e., k = 3 then your program should print 50, 30 and 23. Take input from a user for value k. 3. Sorting Take an array of size 10 in main function. Write sorting(int arr[]) function to sort your array in decreasing order. Display the array before and after calling sorting function in main function.

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

Students also viewed these Databases questions

Question

Explain the factors influencing wage and salary administration.

Answered: 1 week ago

Question

Examine various types of executive compensation plans.

Answered: 1 week ago

Question

1. What is the meaning and definition of banks ?

Answered: 1 week ago