wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

UNIT – I : INTRODUCTION TO C (20 Questions)

Total questions: 100

Worksheet time: 50mins

Name
Class
Date
1.

C language was developed by

a)

Dennis Ritchie

b)

Ken Thompson

c)

Bjarne Stroustrup

d)

James Gosling

2.

Which of the following is a correct C identifier?

a)

2value

b)

value_2

c)

-value

d)

value-2

3.

The extension of a C program file is

a)

.cpp

b)

.exe

c)

.c

d)

.class

4.

Which symbol begins a preprocessor directive?

a)

%

b)

@

c)

&

d)

#

5.

Which is not a data type in C?

a)

int

b)

float

c)

real

d)

char

6.

The value of expression 10/3 in C is

a)

3

b)

3.33

c)

0

d)

10

7.

Operator with highest precedence is

a)

+

b)

*

c)

()

d)

=

8.

sizeof() is a

a)

Keyword

b)

Operator

c)

Macro

d)

Data type

9.

Which is a logical operator?

a)

&

b)

&&

c)

%

d)

*

10.

The default value of uninitialized local variable is

a)

0

b)

Garbage

c)

NULL

d)

-1

11.

Which loop executes at least once?

a)

for

b)

while

c)

do...while

d)

if

12.

A. 3.33 C. 10 D. Compilation Error

a)

3.33

b)

3

c)

10

d)

Compilation Error

13.

Which of the following is not a loop?

a)

for

b)

while

c)

switch

d)

do-while

14.

Which keyword is used for branching?

a)

for

b)

if

c)

do

d)

main

15.

15. 5 % 2 evaluates to

a)

2

b)

1

c)

0

d)

5

16.

The escape sequence for newline is

a)

/n

b)

\n

c)

%n

d)

:n

17.

The output of printf("%d", 3==5);

a)

A. 1

b)

B. 0

c)

C. 3

d)

D. 5

18.

18. Which is not a relational operator?

a)

<=

b)

!=

c)

&&

d)

>

19.

Continue statement

a)

Stops loop

b)

Skips next iteration

c)

Ends program

d)

Exits from function

20.

Which is an assignment operator?

a)

=

b)

==

c)

!=

d)

=>

21.

Array index always starts from

a)

0

b)

1

c)

-1

d)

Depends on compiler

22.

int a[10]; declares

a)

9 elements

b)

10 elements

c)

11 elements

d)

Undefined

23.

Two-dimensional array is also known as

a)

Matrix

b)

Pointer

24.

Which correctly declares a 2D array?

a)

int a[3,3];

b)

int a(3)(3);

c)

int a[3][3];

d)

int[3][3] a;

25.

25. Arrays are stored in

a)

Random order

b)

Sequential memory

c)

Backward memory

d)

Hard disk

26.

Binary search works on

a)

Sorted array

b)

Unsorted array

c)

Random data

d)

Strings only

27.

Linear search complexity is

a)

O(1)

b)

O(n)

c)

O(n²)

d)

O(log n)

28.

Bubble sort complexity is

a)

O(log n)

b)

O(n)

c)

O(n²)

d)

O(n³)

29.

Accessing invalid array index results in

a)

Compilation error

b)

Runtime error

30.

Arrays can store

a)

Different data types

b)

Same data type

c)

Only integers

d)

Only characters

31.

Array name refers to

a)

Value

b)

Base address

c)

Size

d)

Index

32.

int a[3]={1,2,3}; a[3] is

a)

1

b)

3

c)

Garbage

d)

0

33.

The number of elements in int a[4][5] is

a)

4

b)

5

c)

9

d)

20

34.

Which type of array is used to store table?

a)

1D

b)

2D

c)

3D

d)

Dynamic

35.

Merging arrays means

a)

Deleting items

b)

Combining arrays

36.

Which sorting method is fastest on average?

a)

Bubble sort

b)

Selection sort

c)

Insertion sort

d)

Quick sort

37.

A character array is used to store

a)

Numbers

b)

Characters

c)

Strings

d)

Pointers

38.

Index of last element of array a[]

a)

A. 20

b)

B. 19

c)

C. 21

d)

D. 0

39.

int a[5] stores values in

a)

Heap

b)

Stack

c)

Register

d)

ROM

40.

sizeof(int a[5]) if int is 4 bytes

a)

4

b)

5

c)

20

d)

1

41.

Function that calls itself is

a)

Structure

b)

Recursive

c)

Pointer

d)

Loop

42.

Function prototype means

a)

Function definition

b)

Declaration

c)

Documentation

d)

Execution

43.

C uses ______ parameter passing.

a)

Call by value

b)

Call by reference only

c)

Both A and B

d)

None

44.

Pointer stores

a)

Value

b)

Address

c)

Character

d)

String

45.

45. &a gives

a)

Address of a

b)

Value of a

c)

Size of a

d)

Undefined

46.

A. Address B. Pointer value C. Value stored at address D. Size

a)

A. Address

b)

B. Pointer value

c)

C. Value stored at address

d)

D. Size

47.

malloc() returns

a)

Void pointer

b)

int

c)

float

d)

char pointer

48.

free() is used for

a)

Allocation

b)

Deallocation

c)

Sorting

d)

Storing

49.

Which header required for malloc()?

a)

stdio.h

b)

stdlib.h

c)

string.h

d)

malloc.h

50.

50. strlen("C") =

a)

A. 0

b)

B. 1

c)

C. 2

d)

D. Undefined

51.

strcmp() returns

a)

0 for equal

b)

1 for equal

c)

2 for equal

d)

String length

52.

Pointer to array is

a)

int *p

b)

int (*p)[10]

c)

int p

d)

array pointer

53.

Command line arguments use

a)

argc, argv

b)

main()

c)

pointer only

d)

void

54.

Dangling pointer means

a)

Null pointer

b)

Free pointer

c)

Pointer pointing to freed memory

d)

Constant pointer

55.

calloc() initializes memory with

a)

Garbage

b)

Zero

c)

One

d)

-1

56.

Pointer arithmetic supports

a)

A. +, -

b)

B. *, /

c)

C. %, =

d)

D. ++ only

57.

A. Space B. /0 C. \n D. NULL

a)

A. Space

b)

B. /0

c)

C. \n

d)

D. NULL

58.

getchar() returns

a)

string

b)

char

c)

int

d)

float

59.

60. puts() adds

a)

Nothing

b)

newline

c)

tab

d)

space

60.

Structure is a

a)

Data type

b)

Derived data type

c)

Pointer

d)

Function

61.

Structure members are accessed using

a)

. (dot)

b)

->

c)

*

d)

&

62.

Pointer to structure uses

a)

Accessing members of a structure via pointer

b)

Declaring variables only

c)

Performing arithmetic operations

d)

Storing only integer values

63.

Size of union is

a)

Sum of members

b)

Size of largest member

c)

Unknown

d)

0

64.

Nested structure means

a)

Structure inside function

b)

Structure inside structure

c)

Structure inside loop

d)

None

65.

Storage class extern means

a)

Local

b)

Global

c)

Static

d)

Register

66.

67. register variable stored in

a)

RAM

b)

Cache

c)

Register

d)

Stack

67.

static variable retains value

a)

Only in block

b)

Between function calls

c)

Temporarily

d)

Never

68.

Structure is stored in

a)

Sequential bytes

b)

Random

c)

Hard disk

d)

CPU

69.

Union allows

a)

Multiple values at same time

b)

One member at a time

c)

No memory

d)

Dynamic size

70.

Which storage class initializes to zero?

a)

auto

b)

extern

c)

static

d)

register

71.

auto variable lifetime is

a)

Whole program

b)

Within block

c)

System memory

d)

Infinite

72.

Keywords for structures

a)

struct

b)

union

c)

typedef

d)

All

73.

Structure tag is

a)

Memory allocation

b)

Defining alias name

c)

Creating loop

d)

Declaring constant

74.

Which of the following is a member of a structure?

a)

Member

b)

Name

c)

Value

d)

Pointer

75.

Nested structure allows

a)

Unlimited nesting

b)

No nesting

c)

Single level only

d)

Compiler dependent

76.

Which is user-defined data type?

a)

int

b)

float

c)

struct

d)

double

77.

Member alignment depends on

a)

CPU

b)

OS

c)

Compiler

d)

All

78.

sizeof(struct) may include

a)

Padding

b)

Extra data

c)

Random

d)

None

79.

Pointer to structure variable syntax

a)

p->x

b)

p.x

c)

&p.x

d)

++p

80.

File pointer in C is of type

a)

void *

b)

FILE *

c)

int

d)

struct

81.

fopen() returns

a)

int

b)

FILE pointer

c)

NULL only

d)

string

82.

fopen("data.txt","w")

a)

Opens for reading

b)

Opens for writing

c)

Opens for both

d)

Append

83.

fclose() returns

a)

1

b)

0

c)

-1

d)

NULL

84.

"a" mode means

a)

overwrite

b)

append

c)

binary

d)

delete

85.

Which of the following is file output?

a)

console output

b)

file output

c)

scanning

d)

sorting

86.

Which function reads a character from file?

a)

getchar

b)

putc

c)

fgetc

d)

puts

87.

88. rewind()

a)

Moves to end

b)

Moves pointer to beginning

c)

Close file

d)

Delete file

88.

"r" mode fails if

a)

File exists

b)

File does not exist

c)

File is open

d)

File has data

89.

ftell()

a)

Tells file size

b)

Tells current position

c)

Deletes file

d)

Writes file

90.

fseek() is used for

a)

Searching

b)

Positioning

c)

Sorting

d)

Removing

91.

92. fread() stands for

a)

file read

b)

fast read

c)

function read

d)

formatted read

92.

fwrite() writes

a)

Characters

b)

Bytes

c)

Records

d)

All

93.

Which is binary read mode?

a)

r

b)

rb

c)

br

d)

read

94.

feof() checks

a)

file open

b)

file end

c)

file write

d)

file size

95.

perror() used for

a)

Print file

b)

Print error

c)

Protect file

d)

None

96.

File pointer default position after opening "a"

a)

Beginning

b)

End

c)

Middle

d)

Undefined

97.

A. file record C. fast read D. formatted read

a)

file record

b)

file read

c)

fast read

d)

formatted read

98.

Which of the following options is correct?

a)

Clear screen

b)

Flush buffer

c)

Clear RAM

d)

Delete file

99.

fread() returns

a)

Number of records read

b)

Always 1

c)

0

d)

NULL

100.

Text file uses

a)

ASCII

b)

Unicode

c)

Binary

d)

Hex