Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- 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

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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