Question: - Analyze the given function and answer the question below: void f(int arr[], const int MAX, int start) { arr[0] = start; for(int i =

- Analyze the given function and answer the question below:

void f(int arr[], const int MAX, int start)

{

arr[0] = start;

for(int i = 1; i < MAX; i++)

{

arr[i] = arr[i-1] * start;

}

}

Is the following statement true?

f(arr, 5, 4) -> arr = {4, 8, 16, 32, 64} +1 for true

Explain how you know it is true. What is the value of the array after each iteration?

- Consider the code below:

int myList[10];

for(int i = 1; i <= 10; i--)

myList[i] = [i];

Correct the following code so that it correctly sets the value of each element of myList to the index of the element.

Please list all the corrections you made.

- You need to code a function with the following prototype:

bool isPrime(int num);

Write a function to satisfy the above prototype. It should check if num is prime and return true or false.

State any assumptions you may have made.

Explain your algorithm or how you checked if the number is prime.

- Given the declaration:

char str1[21];

char str2[21];

Write a C++ statement that stores "Sunny Day in str1.

Write a C++ statement that stores the length of str1 into the int variable length.

Write a C++ statement that copies the value of name into str2.

Write C++ code that outputs str1 if str1 is less than or equal to str2, and otherwise outputs str2.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!