wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Basics of programming (C/C++)

Total questions: 25

Worksheet time: 12mins

Name
Class
Date
1.

Which header file can be used to define input/output function prototypes and macros?

a)

- math.h

b)

- memory.h

c)

- stdio.h

d)

- dos.h

2.

The correct order of evaluation for the expression “z = x + y * z / 4 % 2 – 1”

a)

* / % = + -

b)

/ * % - + =

c)

- + = * % /

d)

* / % + - =

3.

What is output of below program?


int main()

{

int i,j,count;

count=0;

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

{

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

{

count++;

}

}

printf("%d",count);

return 0;

}

a)

55

b)

54

c)

1

d)

0

4.

What is an Identifier in C Language.?

a)

Name of a Function or Variable

b)

Name of a Macros

c)

Name of Structure or Union

d)

All the above.

5.

Number of Keywords present in C Language are .?

a)

32

b)

34

c)

62

d)

64

6.

To print out 'a' as an integer and 'b' as a decimal, which of the following printf() statement will you use?

a)

printf("%f %lf", a, b)

b)

printf("%f %f", a, b)

c)

printf("%d %f", a, b)

d)

printf("%f %d", a, b)

7.

Which of the following is not a correct variable type?

a)

int

b)

real

c)

float

d)

char

8.

Which of the following is the correct operator to compare two variables?

a)

equal

b)

=

c)

:=

d)

==

9.

What is the only function all C programs must contain?

a)

start()

b)

system()

c)

main()

d)

Program()

10.

Is the syntax for the following C statement correct?:


scanf("%d", input);

a)

True

b)

False

11.

Library function pow() belongs to which header file?

a)

mathio.h

b)

math.h

c)

square.h

d)

stdio.h

12.

You want to show some code if the age is over 18, which is the correct command? (c#)

a)

IF (age > 18)

b)

IF (age >= 18)

c)

IF age > 18

d)

IF (age > "18")

13.

Which is the odd one out?

a)

IF

b)

WHILE

c)

FOR

d)

DO...UNTILL

14.

How many basic data types are there?

a)

3

b)

4

c)

as many as you want

d)

data types?

15.

You need an variable to act as a counter, what would be the best data type to use?

a)

Real/Float

b)

Integer

c)

String

d)

Bool

16.

Choose a right C Statement.

a)

Loops or Repetition block executes a group of statements repeatedly.

b)

Loop is usually executed as long as a condition is met.

c)

Loops usually take advantage of Loop Counter

d)

All the above.

17.

What is the output of C Program.?

int main()

{

int a=25;

while(a <= 27)

{

printf("%d ", a);

a++;

}

return 0;

}

a)

25 25 25

b)

25 26 27

c)

27 27 27

d)

Compiler error

18.

Choose correct Syntax for C Arithmetic Compound Assignment Operators.

a)

a+=b is (a= a+ b)

a-=b is (a= a-b)

b)

a*=b is (a=a*b)

a/=b is (a = a/b)

c)

a%=b is (a=a%b)

d)

All the above.

19.

Choose a correct C for loop syntax.

a)

for(initalization; condition; incrementoperation) { //statements }

b)

for(declaration; condition; incrementoperation) { //statements }

c)

for(declaration; incrementoperation; condition) { //statements }

d)

for(initalization; condition; incrementoperation;) { //statements }

20.

What is the 16-bit compiler allowable range for integer constants?

a)

-3.4e38 to 3.4e38

b)

-32767 to 32768

c)

-32668 to 32667

d)

-32768 to 32767

21.

What is the result after execution of the following code if a is 10, b is 5, and c is 10?

if ((a > b) && (a <= c))

a = a + 1;

else

c = c+1;

a)

a = 10, c = 10

b)

a = 11, c = 10

c)

a = 10, c = 11

d)

a = 11, c = 11

22.

Directives are translated by the

a)

Pre-processor

b)

Compiler

c)

Linker

d)

Editor

23.

Which one of the following is a loop construct that will always be executed once?

a)

for

b)

while

c)

switch

d)

do while

24.

The continue statment cannot be used with

a)

for

b)

while

c)

do while

d)

switch

25.

C is a ____________ programming language

a)

Object oriented Programming

b)

Procedure oriented Programming

c)

Structured programming language

d)

Structure and Procedure Oriented Programming