Font size
WorksheetsUNIT – I : INTRODUCTION TO C (20 Questions)
Total questions: 100
Worksheet time: 50mins
C language was developed by
Dennis Ritchie
Ken Thompson
Bjarne Stroustrup
James Gosling
Which of the following is a correct C identifier?
2value
value_2
-value
value-2
The extension of a C program file is
.cpp
.exe
.c
.class
Which symbol begins a preprocessor directive?
%
@
&
#
Which is not a data type in C?
int
float
real
char
The value of expression 10/3 in C is
3
3.33
0
10
Operator with highest precedence is
+
*
()
=
sizeof() is a
Keyword
Operator
Macro
Data type
Which is a logical operator?
&
&&
%
*
The default value of uninitialized local variable is
0
Garbage
NULL
-1
Which loop executes at least once?
for
while
do...while
if
A. 3.33 C. 10 D. Compilation Error
3.33
3
10
Compilation Error
Which of the following is not a loop?
for
while
switch
do-while
Which keyword is used for branching?
for
if
do
main
15. 5 % 2 evaluates to
2
1
0
5
The escape sequence for newline is
/n
\n
%n
:n
The output of printf("%d", 3==5);
A. 1
B. 0
C. 3
D. 5
18. Which is not a relational operator?
<=
!=
&&
>
Continue statement
Stops loop
Skips next iteration
Ends program
Exits from function
Which is an assignment operator?
=
==
!=
=>
Array index always starts from
0
1
-1
Depends on compiler
int a[10]; declares
9 elements
10 elements
11 elements
Undefined
Two-dimensional array is also known as
Matrix
Pointer
Which correctly declares a 2D array?
int a[3,3];
int a(3)(3);
int a[3][3];
int[3][3] a;
25. Arrays are stored in
Random order
Sequential memory
Backward memory
Hard disk
Binary search works on
Sorted array
Unsorted array
Random data
Strings only
Linear search complexity is
O(1)
O(n)
O(n²)
O(log n)
Bubble sort complexity is
O(log n)
O(n)
O(n²)
O(n³)
Accessing invalid array index results in
Compilation error
Runtime error
Arrays can store
Different data types
Same data type
Only integers
Only characters
Array name refers to
Value
Base address
Size
Index
int a[3]={1,2,3}; a[3] is
1
3
Garbage
0
The number of elements in int a[4][5] is
4
5
9
20
Which type of array is used to store table?
1D
2D
3D
Dynamic
Merging arrays means
Deleting items
Combining arrays
Which sorting method is fastest on average?
Bubble sort
Selection sort
Insertion sort
Quick sort
A character array is used to store
Numbers
Characters
Strings
Pointers
Index of last element of array a[]
A. 20
B. 19
C. 21
D. 0
int a[5] stores values in
Heap
Stack
Register
ROM
sizeof(int a[5]) if int is 4 bytes
4
5
20
1
Function that calls itself is
Structure
Recursive
Pointer
Loop
Function prototype means
Function definition
Declaration
Documentation
Execution
C uses ______ parameter passing.
Call by value
Call by reference only
Both A and B
None
Pointer stores
Value
Address
Character
String
45. &a gives
Address of a
Value of a
Size of a
Undefined
A. Address B. Pointer value C. Value stored at address D. Size
A. Address
B. Pointer value
C. Value stored at address
D. Size
malloc() returns
Void pointer
int
float
char pointer
free() is used for
Allocation
Deallocation
Sorting
Storing
Which header required for malloc()?
stdio.h
stdlib.h
string.h
malloc.h
50. strlen("C") =
A. 0
B. 1
C. 2
D. Undefined
strcmp() returns
0 for equal
1 for equal
2 for equal
String length
Pointer to array is
int *p
int (*p)[10]
int p
array pointer
Command line arguments use
argc, argv
main()
pointer only
void
Dangling pointer means
Null pointer
Free pointer
Pointer pointing to freed memory
Constant pointer
calloc() initializes memory with
Garbage
Zero
One
-1
Pointer arithmetic supports
A. +, -
B. *, /
C. %, =
D. ++ only
A. Space B. /0 C. \n D. NULL
A. Space
B. /0
C. \n
D. NULL
getchar() returns
string
char
int
float
60. puts() adds
Nothing
newline
tab
space
Structure is a
Data type
Derived data type
Pointer
Function
Structure members are accessed using
. (dot)
->
*
&
Pointer to structure uses
Accessing members of a structure via pointer
Declaring variables only
Performing arithmetic operations
Storing only integer values
Size of union is
Sum of members
Size of largest member
Unknown
0
Nested structure means
Structure inside function
Structure inside structure
Structure inside loop
None
Storage class extern means
Local
Global
Static
Register
67. register variable stored in
RAM
Cache
Register
Stack
static variable retains value
Only in block
Between function calls
Temporarily
Never
Structure is stored in
Sequential bytes
Random
Hard disk
CPU
Union allows
Multiple values at same time
One member at a time
No memory
Dynamic size
Which storage class initializes to zero?
auto
extern
static
register
auto variable lifetime is
Whole program
Within block
System memory
Infinite
Keywords for structures
struct
union
typedef
All
Structure tag is
Memory allocation
Defining alias name
Creating loop
Declaring constant
Which of the following is a member of a structure?
Member
Name
Value
Pointer
Nested structure allows
Unlimited nesting
No nesting
Single level only
Compiler dependent
Which is user-defined data type?
int
float
struct
double
Member alignment depends on
CPU
OS
Compiler
All
sizeof(struct) may include
Padding
Extra data
Random
None
Pointer to structure variable syntax
p->x
p.x
&p.x
++p
File pointer in C is of type
void *
FILE *
int
struct
fopen() returns
int
FILE pointer
NULL only
string
fopen("data.txt","w")
Opens for reading
Opens for writing
Opens for both
Append
fclose() returns
1
0
-1
NULL
"a" mode means
overwrite
append
binary
delete
Which of the following is file output?
console output
file output
scanning
sorting
Which function reads a character from file?
getchar
putc
fgetc
puts
88. rewind()
Moves to end
Moves pointer to beginning
Close file
Delete file
"r" mode fails if
File exists
File does not exist
File is open
File has data
ftell()
Tells file size
Tells current position
Deletes file
Writes file
fseek() is used for
Searching
Positioning
Sorting
Removing
92. fread() stands for
file read
fast read
function read
formatted read
fwrite() writes
Characters
Bytes
Records
All
Which is binary read mode?
r
rb
br
read
feof() checks
file open
file end
file write
file size
perror() used for
Print file
Print error
Protect file
None
File pointer default position after opening "a"
Beginning
End
Middle
Undefined
A. file record C. fast read D. formatted read
file record
file read
fast read
formatted read
Which of the following options is correct?
Clear screen
Flush buffer
Clear RAM
Delete file
fread() returns
Number of records read
Always 1
0
NULL
Text file uses
ASCII
Unicode
Binary
Hex
