wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PSPC1

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which of the following is a valid variable name declaration?

a)

Int x;

b)

int 5x;

c)

int x5;

d)

int $x;

2.

Which of the following is a not valid variable name declaration?

a)

int x;

b)

int 5x;

c)

int x5;

d)

int x_5;

3.

Which of the following is a valid C variable name?

a)

main

b)

5x

c)

x 5

d)

xp2$

4.

What is the output of this C code?

#include <stdio.h>

int main()

{

printf("Hello World! %d \n", x);

return 0;

}

a)

Hello World! x;

b)

Hello World! followed by a junk value

c)

Hello World!

d)

Compile time error

5.

What will happen if the below program is executed?

#include <stdio.h>

int main()

{

int main = 3;

printf("%d", main);

return 0;

}

a)

a compile-time error

b)

a run-time error

c)

print 3

d)

infinite loop

6.

Which among the following is NOT a logical or relational operator?

a)

==

b)

!=

c)

||

d)

=

7.

Which among the following is a logical operator?

a)

==

b)

++

c)

||

d)

-

8.

Which of the following is a correct comment?

a)

/*comment*/

b)

*/comment*/

c)

/*comment/*

d)

{*comment*}

9.

The format identifier %d is used for___ data type.

a)

int

b)

char

c)

float

d)

double

10.

The format identifier ____ is used for double data type.

a)

%lf

b)

%d

c)

%D

d)

%c

11.

The format identifier ____ is used for float data type.

a)

%f

b)

%d

c)

%D

d)

%c

12.

What is 'short int' in C programming?

a)

The basic data type of C

b)

Qualifier

c)

short is the qualifier and int is the basic data type

d)

None of the mentioned

13.

Which of the following is not a correct variable type?

a)

float

b)

real

c)

int

d)

double

14.

What is the only function all C programs must contain?

a)

start()

b)

stdio()

c)

main()

d)

include()

15.

What is the output if the below program is executed?

#include <stdio.h>

int main()

{

int x = 3;

if (x<1)

printf("%d", x);

else

printf("Error");

return 0;

}

a)

3 Error

b)

3Error

c)

3

d)

Error

16.

What is the output if the below program is executed?

#include <stdio.h>

int main()

{

int x = 3;

if (x>1)

printf("%d", x);

printf("Error");

return 0;

}

a)

3 Error

b)

3Error

c)

3

d)

Error

17.

What is the output if the below program is executed?

#include <stdio.h>

int main()

{

int x = 3;

if (x>1)

printf("%d", x);

if(x==3)

printf("%d", x);

else

printf("Error");

return 0;

}

a)

33

b)

3Error

c)

3

d)

Error

18.

What is the output if the below program is executed?

#include <stdio.h>

int main()

{

int x = 3;

if (x>1)

printf("%d", x);

else if(x==3)

printf("%d", x);

else

printf("Error");

return 0;

}

a)

33

b)

3Error

c)

3

d)

Error

19.

What is the output if the below program is executed?

#include <stdio.h>

int main()

{

int x = 5;

if (x<1)

printf("%d", x);

else if(x==3)

printf("%d", x);

else

printf("Error");

return 0;

}

a)

33

b)

3Error

c)

3

d)

Error

20.

What is the output if the below program is executed?

#include <stdio.h>

int main()

{

int x = 2;

switch (x)

{

case 1: printf("%d", x);

case 2: printf("Good morning! ");

case 3: printf("Life is beautiful/n");

}

return 0;

}

a)

3

b)

Good morning!

c)

Good morning!Life is beautiful/n

d)

Good morning!Life is beautiful