College

Answer the following questions in C++:

1. Write a code to define an array of 100 numbers of the type `DOUBLE` and initialize it to 0. Note: no loops are required.

2. Write a portion of the program to print a table that converts gallons into liters. One gallon = 3.785 liters. Display the titles "Gallons" and "Liters" first. Then, the program should display gallons from 10 to 20 in one-gallon increments and the corresponding liter equivalents.

3. What is the output of the following program?

```cpp
int list[] = {15, 18, 3, 65, 11, 32, 60, 55, 9};
for (auto num : list)
cout << num % 2 << " ";
cout << endl;
```

4. Given the string `str = "This summer we will drive across the country!";`, what is the output of the following statements?

```cpp
cout << str.size() << endl;
cout << str.substr(12, 20) << endl;
str.erase(20, 25);
str.insert(20, "enjoy Caribbean cruise!");
cout << str << endl;
```

Please provide the C++ code for these tasks.

Answer :

The answer includes solutions for C++ problems about defining an array of a specific type, converting gallons to liters, interpreting output of some specific code, and manipulating strings.

The subject of this question is C++ programming. In question 1, defining an array of 100 numbers of the type DOUBLE can be done as follows: double array[100] = {0};. For the second question regarding a conversion table from gallons to liters, you can follow the following model code:

for(int gallons=10; gallons<=20; gallons++) {cout << gallons << ' ' << gallons * 3.785 << endl;}.

The output of the third program will be the remainder of each number in the list when divided by 2, i.e., 0 for even numbers and 1 for odd numbers. For the last question, the output will first be the number of characters in the string (which is 48), the characters between indices 12 and 31 (which are 'we will drive across the'), and then the modified string (which is 'This summer we will enjoy Caribbean cruise!').

Therefore, the answer includes solutions for C++ problems about defining an array of a specific type, converting gallons to liters, interpreting output of some specific code, and manipulating strings.

To know more about C++ programming, visit:

https://brainly.com/question/33180199

#SPJ11