1) Which of the is a valid name for a variable in C



COP 3223 Section 3 Exam #1

Form A

Fall 2008

9/30/08

Lecturer: Arup Guha

Directions: Answer all multiple choice questions on the scantron. Each question has a single correct answer. In case of ambiguities, choose the most accurate answer. Each of these questions is worth 2 points for a correct answer. Incorrect answers and questions left blank are worth 0 points. Hand in ONLY the scantron, keep the test questions, and take the free response section of the exam.

1) Which of the is a valid name for a variable in C?

A)1number

B)number1

C)var-one

D)else

E)None of the Above

2) Which of the following allows for a single line comment?

A)*

B)*/

C)//

D)\\

E)None of the Above

3) Why is it important to indent in a C program?

A)It makes a program run more efficiently.

B)It makes a program easier to read.

C)It increases the number of variables you can use.

D)Programs can not compile without proper indenting.

E)None of the Above

4) What is the percent code for a string?

A)%c

B)%e

C)%s

D)%x

E)None of the Above

5) What is the value of the following arithmetic expression?

25 - 4*(2 - 13%5) + 6*(4 - 8%9)

A)-3

B)45

C)49

D)53

E)None of the Above

6) What is the value of the following expression?

!(13%7 == 24%9)

A)0

B)1

C)6

D)13

E)None of the Above

7) Let A, B and C represent boolean expressions in the following

complex boolean expression. Of the eight possible truth

settings for A, B and C (one of which is A=false, B=true,

C = false), how many of them make the following expression

true?

!((A || B) && C)

A)3

B)5

C)6

D)7

E)None of the Above

8) What is the problem with the following segment of code?

int radius;

double area = 3.14*radius*radius;

printf("Enter the radius.\n");

scanf("%d", &radius);

printf("The area is %lf.\n", area);

A)In line 1, radius needs to be declared as a double.

B)In line 2, radius has no value, so area is assigned a meaningless value.

C)In line 4, there should be no ampersand.

D)In line 5, the percent code used should be d.

E)None of the Above

9) What is the "l-value" in the following C statement?

value = 2*number;

A)value

B)number

C)2

D)=

E)None of the Above

10) Which of the following is NOT a relational operator?

A)>

B)=

C)>=

D)= 21)

printf("time to go out!\n");

else

printf("time to study!\n");

A)time to go out!n

B)time to study!

C)time to study!n

D)"time to study!"

E)None of the Above

12) What is the output of the following segment of code?

int a = 3, b = 5;

if (a > 2)

if (b > 7)

printf("A");

else

printf("B");

printf("C");

A)B

B)AC

C)BC

D)

E)None of the Above

13) What is the output of the following segment of code?

int grade = 99;

if (grade > 90)

printf("A");

if (grade > 80)

printf("B");

if (grade > 70)

printf("C");

else if (grade > 60)

printf("D");

A)A

B)B

C)C

D)ABC

E)None of the Above

14) What is the output of the following segment of code?

int a = 7;

if (a > 12);

a = 9;

printf("%d", a);

A)7

B)9

C)12

D)21

E)None of the Above

15) What is the output of the following segment of code?

int a = 5;

if (a > 9)

printf("A");

printf("B");

printf("C");

printf("D");

A)A

B)B

C)D

D)BCD

E)None of the Above

16) How many times will go ucf! get printed when the following segment

of code executes?

int i;

for (i=3; i ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download