Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

11... Why use modular compilation? Select one: a. To improve the executable’s co

ID: 3874327 • Letter: 1

Question

11...

Why use modular compilation?

Select one:

a. To improve the executable’s computation performance.

b. To reduce the time required to recompile the executable.

c. To save the programmer the hassle of finding all the dependencies.

d. Because file linking is necessary.

12...

Which function is called in the following code?

double CalcFt(double inches) {

   return inches * 12.0;

}

int CalcFt(int inches) {

   return inches * 12;

}

int main() {

   int inches = 24;

   cout << CalcFt(24);

   return 0;

}

Select one:

a. double CalcFt(double inches)

b. int CalcFt(int inches)

c. Both functions are called.

d. Error: Cannot given same name to multiple functions.

13....

Given the command-line argument:

a.out Jane Doe 23 Ben Smith 22

What is the output of the following program myprog.exe?

int main(int argc, char* argv[]) {

   cout << argc;

   return;

}

Select one:

a. 7

b. 6

c. 5

d. 4

14....

Where does the preprocessor look for “std” in the line:

using namespace std;

Select one:

a. The same directory/folder as the including file.

b. The system’s standard library directory/folder.

c. Custom files cannot be included without < > notation.

d. Nowhere, preprocessor only looks at lines starting with #.

15.....

void PrintName() {

   cout << "First name is Tom. ";

   cout << "Last name is Jones." << endl;

   return;

}

int main() {

   PrintName();

   PrintName();

   return 0;

}

How many output statements would execute in total?

Select one:

a. 1

b. 2

c. 4

d. 8

16....

The following is an example of a function stub:

int CountOfAlpha(string input) {

   return 0;

}

Select one:

a. True

b. False

17...

Which of the following is NOT a benefit of separate files:

Select one:

a. Separate files insures that main does not grow too large.

b. Separate files increases compilation speed.

c. Separate files allows the separated files to be used in other programs.

d. All of the above are benefits.

18....

Which function evaluates whether a character c is uppercase?

Select one:

a. isalnum(c)

b. isalpha(c)

c. toupper(c)

d. isupper(c)

19.....

Define a character array named stateName with 50 elements and initialize the array to the string (without spaces): Kansas.

Select one:

a. char stateName[50] = ‘Kansas’;

b. char stateName[50] = “Kansas”;

c. char stateName(50) = “Kansas”;

d. char stateName[50]; stateName = ‘Kansas’;

20.....

Given the following makefile:

driveSim.exe : main.o carFcts.o

    g++ main.o carFcts.o -o driveSim.exe    # (1)

main.o : main.cpp carFcts.h

    g++ -Wall -c main.cpp             # (2)

carFcts.o : carFcts.cpp carFcts.h

    g++ -Wall -c carFcts.cpp            # (3)

Assume that make has already run. Which commands will be executed if carFcts.h is changed and make is called?

Select one:

a. (1), (2), (3)

b. (2), (3)

c. (1), (2)

d. (1), (3)

Explanation / Answer

11. Why use modular compilation?

Answer: Option d. Because file linking is necessary.

12...
Which function is called in the following code?

double CalcFt(double inches) {
return inches * 12.0;
}
int CalcFt(int inches) {
return inches * 12;
}
int main() {
int inches = 24;
cout << CalcFt(24);
return 0;
}

Answer: Option b. int CalcFt(int inches)

Explanation:

program:

#include <iostream>
using namespace std;
double CalcFt(double inches) {
return inches * 12.0;
}
int CalcFt(int inches) {
return inches * 12;
}
int main() {
int inches = 24;
cout << CalcFt(24);
return 0;
}

Output: 288

Given the command-line argument:

a.out Jane Doe 23 Ben Smith 22

What is the output of the following program myprog.exe?

int main(int argc, char* argv[]) {
cout << argc;
return;
}
Answer: 1
Explanation:
Program:

#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
cout << argc;
return 0;
}

Output: 1

14...
Where does the preprocessor look for “std” ?

Answer: Option d. Nowhere, preprocessor only looks at lines starting with #.

15.....
void PrintName() {
cout << "First name is Tom. ";
cout << "Last name is Jones." << endl;
return;
}
int main() {
PrintName();
PrintName();
return 0;
}
How many output statements would execute in total?

Answer: Option b. 2

Explanation:

Program:

#include <iostream>
using namespace std;
void PrintName() {
cout << "First name is Tom. ";
cout << "Last name is Jones." << endl;
return;
}
int main() {
PrintName();
PrintName();
return 0;
}

Output:

First name is Tom.
Last name is Jones.
First name is Tom.
Last name is Jones.

16....

The following is an example of a function stub:

int CountOfAlpha(string input) {

   return 0;

}

Select one:

Answer:b. False

17...
Which of the following is NOT a benefit of separate files:

Answer: Option d. All of the above are benefits.

18....
Which function evaluates whether a character c is uppercase?
Select one:

Answer: Option b.isalpha(c)

19.....
Define a character array named stateName with 50 elements and initialize the array to the string (without spaces): Kansas.
Select one:

Answer: Option b. char stateName[50] = "Kansas";

20.....
Given the following makefile:

driveSim.exe : main.o carFcts.o
g++ main.o carFcts.o -o driveSim.exe # (1)
main.o : main.cpp carFcts.h
g++ -Wall -c main.cpp # (2)
carFcts.o : carFcts.cpp carFcts.h
g++ -Wall -c carFcts.cpp # (3)
Assume that make has already run. Which commands will be executed if carFcts.h is changed and make is called?
Select one:
Answer: Option c. (1), (2)