Question
____ 1. Assume you have the following declaration char nameList[100];. Which of the following ranges is valid for the index of the array nameList? a.
____ 1. Assume you have the following declaration char nameList[100];. Which of the following ranges is valid for the index of the array nameList?
a. | 0 through 99 | c. | 1 through 100 |
b. | 0 through 100 | d. | 1 through 101 |
____ 2. Assume you have the following declaration int beta[50];. Which of the following is a valid element of beta?
a. | beta['0'] | c. | beta[0] |
b. | beta['1'] | d. | beta[50] |
____ 3. Suppose that sales is an array of 50 components of type double. Which of the following correctly initializes the array sales?
a. | for (int 1 = 1; j <= 49; j++) sales[j] = 0; |
b. | for (int j = 1; j <= 50; j++) sales[j] = 0; |
c. | for (int j = 0; j <= 49; j++) sales[j] = 0.0; |
d. | for (int j = 0; j <= 50; j++) sales[j] = 0.0; |
____ 4 What is stored in alpha after the following code executes?
int alpha[5];
int j;
for (j = 0; j < 5; j++)
{
alpha[j] = 2 * j;
if (j % 2 == 1)
alpha[j - 1] = alpha[j] + j;
}
a. | alpha = {0, 2, 4, 6, 8} |
b. | alpha = {0, 2, 9, 6, 8} |
c. | alpha = {0, 3, 4, 7, 8} |
d. | alpha = {3, 2, 9, 6, 8} |
b. | 8 | d. | 10 |
Programming Questions
Write a C++ program that lets the user enter rainfall for each of 12 months into an array of doubles. The program should calculate and display the total rainfall for the year and the average monthly rainfall.
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