wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Programming

Total questions: 30

Worksheet time: 3600secs

Name
Class
Date
1.

What is the output of the below code snippet?

a)

A - a=5, b=3

b)

B - a=5, b=3, c=0

c)

C - a=5, b=3, 0

d)

D - compile error

2.

What is the output of the following program?

a)

A - 4

b)

B - 6

c)

C - 2 6

d)

D - 2 4

3.

Following is the invalid inclusion of a file to the current program. Identify it.

a)

A - #include <file>

b)

B - #include “file”

c)

C - #include < file

d)

D - All of the above are invalid.

4.

What is the output of the following program?

a)

A - NULL

b)

B - 0

c)

C - Compile error

d)

D - Runtime error.

5.

Which of the following functions disconnects the stream from the file pointer.

a)

A - fremove()

b)

B - fclose()

c)

C - remove()

d)

D - file pointer to be set to NULL

6.

A Variable name in C includes which special symbols?

a)

A - * (asterisk)

b)

B - # (Hash)

c)

C - + (Addition)

d)

D - _ (underscore)

7.

The given below program allocates the memory, what function will you use to free the allocated memory?

a)

A - memfree(int p);

b)

B - free(p);

c)

C - dealloc(p);

d)

D - Both, free(p); & dealloc(p);

8.

Which scanf() statement will you use to scan a float value (a) and double value (b)?


Float a;

Double b;

a)

A - scanf("%f %f", &a, &b);

b)

B - scanf("%lf % lf ", &a, &b);

c)

C - scanf("%Lf %Lf", &a, &b);

d)

D - scanf("%f %lf", &a, &b);

9.

To print a double value which format specifier can be used?

a)

A - %L

b)

B - %lf

c)

C - %Lf

d)

D - None of the above

10.

According to ANSI specification, how to declare main () function with command-line arguments?

a)

A - int main(int argc, char *argv[])

b)

B - int char main(int argc, *argv)

c)
d)

D - None of the above

11.

What is the output of the following program?

a)

A - Compile error

b)

B - 5

c)

C - 6

d)

D - Garbage value

12.

What is the output of the following program?

a)

A - Garbage character.

b)

B - A

c)

C - 65

d)

D - Compile error

13.

Identify the incorrect file opening mode from the following.

a)

A - r

b)

B - w

c)

C - x

d)

D - a

14.

What is the output of the following program?

a)

A - 10

b)

B - 20

c)

C - 11

d)

D - 21

15.

What is the output of the following program?

a)

A - Hello

b)

B - Compile error: there is no macro called “undef”

c)

C - Compile error: improper place of #undef

d)

D - Compile error: NULL is undeclared.

16.

In Windows & Linux, how many bytes exist for near, far and huge pointers?

a)

A - Near: 1, far: 4, huge: 7

b)

B - near: 4, far: 4, huge: 4

c)

C - near: 0, far: 4, huge: 4

d)

D - near: 4, far: 5, huge: 6

17.

The given below program allocates the memory, what function will you use to free the allocated memory?

a)

A - memfree(int p);

b)

B - free(p);

c)

C - dealloc(p);

d)

D - Both, free(p); & dealloc(p);

18.

How many times the given below program will print "India"?

a)

A - Unlimited times

b)

B - 21 times

c)

C - 0 times

d)

D - 20 times

19.

What will be the resultant of the given below program?

a)

A - IndiaMAX 1, 7, 11, 0

b)

B - IndiaMAX 1, 7

c)

C - Only 4

d)

D - 1, 7, 11, 0

20.

In the given below statement, what does the “pf” indicate?


 int (*pf)();

a)

A - pf is a pointer of a function which return int

b)

B - pf is a pointer

c)

C - pf is a function pointer

d)

D - None of the above

21.

int x=~1; What is the value of 'x'?

a)

A - 1

b)

B - -1

c)

C - 2

d)

D - -2

22.

What is the following program doing?

a)

A - Trying to open “a.txt” in read mode

b)

B - Trying to open “a.txt” in write mode.

c)

C - “stream” is an invalid identifier

d)

D - Compile error

23.

First operating system designed using C programming language.

a)

A - DOS

b)

B - Windows

c)

C - UNIX

d)

D - Mac

24.

Does both the loops in the following programs prints the correct string length?

a)

A - Yes, both the loops prints the correct length

b)

B - Only for loop prints the correct length

c)

C - Only while loop prints the correct length

d)

D - Compile error in the program.

25.

A local variable is stored in ___

a)

A - Code segment

b)

B - Stack segment

c)

C - Heap segment

d)

D - None of the above

26.

In normalized form, if the binary equivalent of 5.375 is “0100 0000 1010 1100 0000 0000 0000 0000” then what will be the output of the program in Intel core machine?

a)

A - 40 AC 00 00

b)

B - 00 00 AC 40

c)

C - 00 00 CA 04

d)

D - None

27.

In Decimal system you can convert the binary number 1011011111000101 very easily

a)

A - Yes

b)

B - Hexadecimal system

c)

C - Octal system

d)

D - Both, Octal & Decimal

28.

Which of the following header file can be used to define the NULL macro?

a)

A - stdio.h, locale.h, stddef.h, stdlib.h, string.h,

b)

B - stddef.h, locale.h, math.h, stdlib.h, string.h,

c)

C - time.h, wchar.h, math.h, locale.h,

d)

D - math.h

29.

Which files will get closed through the fclose() in the following program?

a)

A - "ABC"

b)

B - "ACD"

c)

C - "ADF"

d)

D - Return error

30.

Choose the function that is most appropriate for reading in a multi-word string?

a)

A - strnset()

b)

B - scanf()

c)

C - strchr()

d)

D - gets()