Programing in C

profiledsis_1
assement.docx

Question 1

Which statement will read a floating point value from the keyboard and store it in the variable x?

A.

printf(“float = %f”, x);

B.

scanf(“%f”, &x);

C.

scanf(“&f”, %x);

D.

scanf(“%d”, &x);

Question 2

Structures can at most be nest 3 deep?

True

False

5 points

Question 3

What is the equivalent C expression for the area of a circle (PI times radius squared)?

A.

3.14 x r x r

B.

3.14 * r^2

C.

3.14r^2

D.

3.14 * r * r

5 points

Question 4

Which statement will print the following variables correctly?int x; float y;

A.

printf(“x = %d y = %lf”, x , y);

B.

printf(“x = %f y = %f”, x , y);

C.

printf(“x = %d y = %d”, x, y);

D.

printf(“x = %d y = %f”, x , y);

5 points

Question 5

A procedure consisting of a number of precisely defined steps for solving a problem is called a(n):

A.

program

B.

algorithm

C.

compiler

D.

pseudo-code

5 points

Question 6

What will be the value of the floating point variable var1 after the following scanf statement if the user enters 123.45456.78 at the keyboard?

scanf(“%5f%7f”, &var1, &var2);

A.

123.45

B.

12345

C.

45456

D.

123.4

5 points

Question 7

A for loop can count by 10?

True

False

5 points

Question 8

Which of the following is NOT one of the three basic control structures in C?

A.

selection

B.

sequence

C.

flow

D.

repetition

5 points

Question 9

Every C program must have a function called main?

True

False

.

5 points

Question 10

The program that translates a high-level source program into machine code or object code is called a(n)

A.

Compiler

B.

CPU

C.

Arithmetic Logic Unit (ALU)

D.

Linker

.

5 points

Question 11

In a while loop, the initialization, condition, and increment are all in the header?

True

False

.

5 points

Question 12

What will be the value of y after the following loop is run?

int x;

int y=10;

for(x=0; x<10;x++) {

--y;

}

A.

1

B.

0

C.

10

D.

-1

.

5 points

Question 13

Which of the following used to describe the steps to be carried out by the computer in a semi-formal verbal/mathematical form?

A.

algorithm

B.

pseudo-code

C.

compiler

D.

program

.

5 points

Question 14

Some statements in C do not terminate with a semi-colon?

True

False

5 points

Question 15

What will be the output of the following printf statement if the user enters 1234567890 at the keyboard when the scanf statement is executed?

int x, y, z;

scanf(“%2d%3d%5d”, &x, &y, &z);

printf(“%d %d %d”, x, y, z);

A.

12 34 567890

B.

12 345 67890

C.

1234567890

D.

nothing, this is incorrect syntax

.

5 points

Question 16

Which kind of loop is best if the body of the loop must execute at least one time?

A.

while

B.

for

C.

nested-iterative

D.

do-while

.

5 points

Question 17

What will be the value of x below?

int a=2, b=3, c=4;

x=a + b * b + c * a;

A.

66

B.

38

C.

19

D.

23

.

5 points

Question 18

What will be the value of k after the following loop is run?

int i, j, k=0;

for (i=0; i<10;i++)

for(j=0;j<10;j++)

k++;

A.

10

B.

99

C.

100

D.

1000

.

5 points

Question 19

Relational expressions evaluate to 0 or 1?

True

False

.

5 points

Question 20

What will be the result of the following printf statement?

float x = 1.0, y = 3.0;

printf(“%.4f”, x / y);

A.

.3333

B.

.3334

C.

.3

D.

1.0/3.0