Docsity

Solved Exam 1 for Structure Programming in C | CSCE 206, Exams of Computer Science

Toggle sidebar
bg1
TRUE/FALSE. Fill 'A' if the statement is true and 'B' if the statement is false.
1)
The fixed manipulator causes a number to be displayed in scientific notation.
1)
2)
Software engineering is a field that encompasses designing, writing, testing, debugging,
documenting, modifying, and maintaining computer hardware.
2)
3)
Escape sequences are always stored internally as a single character.
3)
4)
If you want to know the length of the string that is stored in a string object, you can call the
object’s size member function.
4)
5)
The C++ language requires that you give variables names that indicate what the variables are used
for.
5)
6)
A CPU really only understands instructions that are written in machine language.
6)
7)
A significant difference between the get function and the >> operator is that get reads the first
character typed, even if it is a space, tab, or the [Enter] key.
7)
8)
C++ does not have a primitive data type for storing strings of characters.
8)
9)
If you do not follow a consistent programming style, your programs will generate compiler errors.
9)
10)
When the fixed manipulator is used, the value specified by the setprecision manipulator will be the
total number of digits displayed.
10)
11)
Floating point constants are stored in memory as doubles.
11)
12)
The cin << statement will stop reading input when it encounters a newline character.
12)
13)
Arithmetic operators that share the same precedence have right to left associativity.
13)
14)
When C++ is working with an operator, it strives to convert the operands to the same type.
14)
15)
When a program uses the setw manipulator, the iosetwidth header file must be included in a
preprocessor directive.
15)
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
16)
What will the value of x be after the following statements execute?
int x = 0;
int y = 5;
int z = 4;
x = y + z * 2;
16)
A)
13
B)
C)
0
D)
unknown
E)
5
1
F
F
T
F
F
T
T
T
F
F
T
T
F
T
F
A
pf3
pf4
pf5
pf8

Partial preview of the text

Download Solved Exam 1 for Structure Programming in C | CSCE 206 and more Exams Computer Science in PDF only on Docsity!

TRUE/FALSE. Fill 'A' if the statement is true and 'B' if the statement is false.

  1. The fixed manipulator causes a number to be displayed in scientific notation. 1)

  2. Software engineering is a field that encompasses designing, writing, testing, debugging, documenting, modifying, and maintaining computer hardware.

  1. Escape sequences are always stored internally as a single character. 3)

  2. If you want to know the length of the string that is stored in a string^ object, you can call the object’s size^ member function.

  1. The C++ language requires that you give variables names that indicate what the variables are used for.
  1. A CPU really only understands instructions that are written in machine language. 6)

  2. A significant difference between the get function and the >> operator is that get reads the first character typed, even if it is a space, tab, or the [Enter] key.

  1. C++^ does not have a primitive data type for storing strings of characters.^ 8)

  2. If you do not follow a consistent programming style, your programs will generate compiler errors. 9)

  3. When the fixed manipulator is used, the value specified by the setprecision manipulator will be the total number of digits displayed.

  1. Floating point constants are stored in memory as doubles. 11)

  2. The^ cin <<^ statement will stop reading input when it encounters a newline character.^ 12)

  3. Arithmetic operators that share the same precedence have right to left associativity. 13)

  4. When C++ is working with an operator, it strives to convert the operands to the same type. 14)

  5. When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive.

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

  1. What will the value of x be after the following statements execute?

int x = 0; int y = 5; int z = 4; x (^) = y (^) + z * 2;

A) 13 B) 18 C) 0 D) unknown E) 5

F F T F F T T T F F T T F T F A

  1. In the process of translating a source file into an executable file, which of the following is the correct sequence?

A) source code, compiler, modified source code, preprocessor, object code, linker, executable code B) source code, preprocessor, modified source code, linker, object code, compiler, executable code C) preprocessor, source code, compiler, executable code, linker, modified source code, object code D) source code, linker, object code, compiler, modified source code, preprocessor, executable code E) source code, preprocessor, modified source code, compiler, object code, linker, executable code

  1. Look at the following program and answer the question that follows it.

1 //This program displays my gross wages. 2 //I worked 40 hours and I make $20.00 per hour. 3 # include 4 using namespace std; 5 6 int main( ) 7 { 8 int hours; 9 double payRate, grossPay; 10 11 hours = 40; 12 payRate = 20.0; 13 grossPay = hours * payRate; 14 cout << "My gross pay is $" << grossPay << endl; 15 return 0; 16 }

Which line(s) in this program cause output to be displayed on the screen?

A) 13 B) 15 C) 13 and 14 D) 8 and 9 E) 14

  1. What will the following code display?

int number = 7; cout << "The number is " << "number" << endl;

A) The number is 7 B) The number is number C) The number is 0 D) The number is E) None of these

E

E

B

  1. Unix and Windows 2000 are examples of ________ operating systems. 26) A) single tasking B) multi- tasking C) Macintosh D) command- driven E) None of these

  2. Assume that a program has the following variable definition:

char letter;

Which of the following statements is(are) valid? (choose the most accurate answer)

A) letter = Z; B) letter (^) = "Z"; C) letter = 65; D) letter = 'Z'; E) C and D

  1. This stream manipulator forces cout to print the digits in fixed- point notation. 28) A) setprecision(2) B) fixed C) setfixed(2) D) setw(2) E) None of these

  2. When converting some algebraic expressions to C++, you may need to insert ________ that do not appear in the algebraic expression.

A) calculations B) exponents C) parentheses D) coercions E) None of these

  1. What will the value of x be after the following statements execute?

int x; x = 8 /14;

A) 0 B) 4 C) 4.5 D) unknown E) 5

B

E

B

C

A

  1. What will the following code display?

cout << "Four\n" << "score\n"; cout << "and" << "\nseven"; cout << "\nyears" << " ago" << endl;

A) Four score and seven years ago B) Four score and seven years ago C) Four score and seven years ago D) Four score and seven years ago E) None of these

  1. What is the value of number after the following statements execute?

int number = 10; number += 5; number - = 2; number *= 3;

A) 2 B) 30 C) 3 D) 15 E) 10

  1. Assume that x is an int variable. What value is assigned to x after the following assignment statement is executed?

x = - 3 + 4 % 6 /5;

A) - 3

B) 1

C) 0

D) 2

E) None of these

  1. What will the value of x be after the following statements execute?

int x; x = 2 % 4;

A) 0.45 B) 4 C) 2 D) unknown E) 3

C

D

A

C

  1. Which is true about the following statement?

cout << setw(4) << num4 << " ";

A) It outputs "setw(4)" before the value in the variable num4. B) It should use setw(10) to output the value in the variable num10. C) It inputs up to four characters stored in the variable num4. D) It allows four spaces for the value in the variable num4. E) None of these

  1. In a broad sense, the two primary categories of programming languages are: 42) A) low- level and high- level B) single- tasking and multi- tasking C) COBOL and BASIC D) mainframe and PC E) None of these

  2. Assuming you are using a system with 1- byte characters, how many bytes of memory will the following string literal occupy?

"William"

A) 8

B) 7

C) 1

D) 14

E) None of these

  1. This is a set of rules that must be followed when constructing a program. 44) A) key words B) portability C) operators D) punctuation E) syntax

  2. This term refers to the programmer reading the program from the beginning and stepping through each statement.

A) spot checking B) software engineering C) pseudocoding D) desk checking E) None of these

  1. What will the value of result be after the following statement executes?

result = 6 - 3 * 2 + 7 - 10 /2 ;

A) 6 B) 2 C) 8 D) 1.5 E) 3

D

A

A

E

D

  1. This statement will pause the screen, until the [Enter] key is pressed. 47) A) cin.input(); B) cin.get(); C) cin.ignore(); D) cin.getline(); E) cin;

  2. This is a volatile type of memory, used for temporary storage. 48) A) a floppy disk B) ALU C) a hard disk D) RAM E) None of these

  3. Which line in the following program will cause a compiler error?

1 #include 2 using namespace std; 3 4 int main( ) 5 { 6 const int MY_VAL; 7 MY_VAL = 77; 8 cout << MY_VAL << endl; 9 return 0; 10 }

A) 8 B) 7 C) 6 D) 9 E) 10

  1. What will the value of x be after the following statements execute?

int x; x = 18.0 /4;

A) 4.

B) 4

C) 0

D) 5

E) None of above

B

B

C

D