##### O Level | January 2012 | M3-R4 (Prog. and Prob. Solving Through ‘C’ Language)

1.1 What would be value of j after the following is executed?

k=17;
j=6;
if (k < 10)
j=8;
j=j+1;
j=j+2;

A) 8

B) 9

C) 7

D) 10

C

1.2 What will be output after compilation and execution of the following code?

#include<stdio.h>
int main(){ int array={5}; int i;
for (i=0;i<=2;i++)
printf("%d ",array[i]); return 0;}

A) 5 garbage garbage

B) 5 0 0

C) 0 0 0

D) 5 5 5

A

1.3 In an assignment statement a=b; which of the following statement is true ?

A) The variable a and the variable b are same.

B) The value of b is assigned to variable a but if b changes later, it will not effect the value of variable a.

C) The value of b is assigned to variable a but if b changes later, it will effect the value of variable a.

D) The value of variable a is assigned to variable b, and the value of variable b is assigned to variable a.

B

1.4 Which code will print k 20 times?

A) for (i=1; i < 20; i++) printf (“k”);

B) for (i=1; i = 20; i++) printf (“k”);

C) for (i=0; i < 20; i++) printf (“k”);

D) for (i=0; i <= 20; i++) printf (“k”);

D

1.5 When the following piece of code is executed, what happens?
b = 3; a = b++;

A) a contains 3 and b contains 4

B) a contains 4 and b contains 4

C) a contains 4 and b contains 3

D) a contains 3 and b contains 3

A

1.6 What is the value of r after this code is executed?

r=2;
k=8;
if (r>3 || k>6 && r<5 ||k>10)
r=9;
else
r=6

A) 9

B) 2

C) 6

D) 8

A

1.7 Which of the following is not a valid relational operator?

A) <

B) =

C) >=

D) <=

B

1.8 What is the final value of x when the code int x; for(x=0; x<10; x++) {} is executed?

A) 10

B) 9

C) 0

D) 1

A

1.9 For the function

int operation (int A[], int n)
{

}
Which is the appropriate calling statement from main program?

A) s=operation(A[], 6)

B) operation(A, 6)

C) k=operation(A, 6)

D) d=operation(int A, 6)

C

1.10 Which is an incorrect variable name?

A) Id_No

B) ID_NO

C) IdNo

D) Id No

D