Cgs3460 – Exam#1 Name: answer key 1/30/04 Signature




Yüklə 36.34 Kb.
tarix20.04.2016
ölçüsü36.34 Kb.

CGS3460 – Exam#1 Name: _______ ANSWER KEY _______

1/30/04 Signature: __________________________

1. Lines beginning with the _______________ let the computer know that the rest of the line is a comment.

(a) /*
(b) **

(c) REM

(d) <<
ANS: (a)
2 Which of the following must every C++ program have?

(a) main

(b) #direct

(c) //

(d)

ANS: (a)
3 Every statement in C must end with a

(a) period (.)

(b) semicolon (;)

(c) colon (:)

(d) backslash (/)

ANS: (b)
4 Which of the following is an escape sequence for ‘next line’?

(a) \n

(b) \\

(c) \~

(d) \”

ANS: (a)
5. The following line is an example of a __________.



printf( “Welcome to C!” );

a) function

b) block

c) statement

d) header

ANS: (c)

6. In a printf, a backslash is printed by enclosing in quotes

a) \

b) \\

c) /\

d) //

ANS: (b)


7. The escape sequence for horizontal tab is __________.

a) \tab

b) \t

c) \horizontaltab

d) \n

ANS: (b)


8. Which of the following is not a valid integer value?

(a) -3

(b) 0

(c) 2134859

(d) 1.1

ANS: (d)
9. Which of the following is an invalid identifier (variable name)?

(a) _Test

(b) TEST

(c) 5test

(d) test1

ANS: (c)
10. Which statement prints “hi” on the screen?

(a) printf("hi");

(b) print "hi";

(c) printf "hi";

(d) none of the above

ANS: (a)

11. The __________ sign is also known as the __________ operator.

(a) +, assignment

(b) =, assignment

(c) *, stream manipulator

(d) /, stream insertion

ANS: (b)
12. A(n) __________ is a location in the computer's memory where a value can be stored for use by a program.

a) unknown

b) directive

c) variable

d) declaration

ANS: (c)
13. Which of the following statements is false?

a) C is case sensitive.

b) Uppercase and lowercase letters are different in C.

c) identifier and IdEnTiFiEr are identical identifiers in C.

d) Identifiers can not start with a number.

ANS: (c)
14. Variable names actually correspond to __________.

(a) locations in the computer's memory

(b) operators

(c) integers

(d) data types

ANS: (a)
15. When a number gets assigned to a variable that already has a value __________.

(a) the new number overwrites the previous value at that memory location

(b) the new number gets assigned to a neighboring memory location

(c) the computer issues an error

(d) the new value is destroyed and the old value remains

ANS: (a)
16. Which operation will find the remainder when 15 is divided by 6?

(a) 15 / 6

(b) 15 % 6

(c) 15 ^ 6

(d) 15 * 6

ANS: (b)
17. Which statement about precedence is false?

a) Parentheses may be used to force the order of evaluation to occur in any sequence desired by the programmer.

b) Nested, or embedded parentheses are evaluated last.

c) Multiplication has a higher precedence than addition.

d) Subtraction has a lower precedence than division.

ANS: (b)
18. Which of the following is an equality operator?

(a) ==

(b) =

(c) >

(d) >=

ANS: (a)
19. The compile stage is when ____________.

(a) the object code is linked with code for functions in other files

(b) the C program is translated into machine language code

(c) the program is executed one instruction at a time

(d) the program is placed in memory

ANS: (b)
20. If x = 3, which of the following sets x to 7?

(a) x *= 4;

(b) x += 4;

(c) x =+ 4;

(d) x + 4 = x;

ANS: (b)

21. Which assignment expression is equivalent to c = c / 2 ?

a) c /= 2c

b) c / c = 2

c) c /= 2

d) c =/ 2

ANS: (c)
22. Which of the following will not increment variable c by one?

(a) c + 1;

(b) c++;

(c) ++c;

(d) c += 1;

ANS: (a)
23. An example of a unary operator is

(a) a relational operator

(b) an assignment operator

(c) an increment operator

(d) a logical operator

ANS: (c)

24. Consider the following code, what is the output?



int x=12;

printf(“%d”, x);

(a) 6


(b) 12

(c) nothing

(d) a syntax error is produced

ANS: (b)
25. Of the following, which is an error?

(a) putting a space between float and the variable name

(b) dividing by zero

(c) initialize counter to one by using int counter = 1;

(d) no semicolon after #include



ANS: (b)





Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azrefs.org 2016
rəhbərliyinə müraciət

    Ana səhifə