Question
1)Which one of the following options is a valid line of code for displaying the eigth element of myarray ? Select one: a. cout <
1)Which one of the following options is a valid line of code for displaying the eigth element of myarray?
Select one:
a. cout << myarray(7);
b. cout << myarray[7];
c. cout << myarray[8];
d. cout << myarray(8);
2) Consider the following code snippet:
int numarray[6];
for (int cnt = 1; cnt < 6; cnt++)
{ numarray[cnt] = cnt + 1; }
Which of the following statements is correct about the given code snippet?
Select one:
a. The for loop initializes all the elements except the first element.
b. The for loop initializes all the elements of the array.
c. The for loop inititalizes all the elements except the last element.
d. The for loop initializes all the elements except the first and last elements.
3) Consider the following code snippet:
int size1 = 0; int size2 = 0; int num1[20]; int num2[10];
for (int cnt = 0; cnt < 5; cnt = cnt++)
{ num1[cnt] = cnt + 1;
size1++;
if (size2 < 4)
{ num2[cnt] = cnt + 1;
size2++;
}
}
What is the value of the size2 variable after executing the given code snippet?
Select one:
a. 4
b. 5
c. 3
d. 6
4) Which one of the following is a valid signature (prototype) of a function with an integer array parameter of size 10?
Select one:
a. void func (int arr[ ]);
b. void func (int arr[size); // size is a variable
c. void func(int arr[10])
d. void func([ ] int arr)
5) Consider the following code snippet:
int cnt = 0; int myarray[5];
for (int i = 0; i < 5; i++)
{ myarray[i] = cnt;
cnt+=2;
}
What is the value of myarray[2] after the code snippet is executed?
Select one:
a. 4
b. 8
c. 0
d. 6
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started