Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CP midsem2 set 1

Total questions: 31

Worksheet time: 32mins

Name
Class
Date
1-3.

(mandatory) Enter your details carefully :

1.

Enter your 11 digit enrollment number:

4 lines
2.

Enter your class (DC1/DC2/DC3):

4 lines
3.

Enter your full name in following format (firstname lastname) ex. Pooja Raval

4 lines
4.
What is a union?
a)
A data structure that stores elements in a first-in-first-out (FIFO) manner.
b)
A data structure that stores elements in a last-in-first-out (LIFO) manner.
c)
A data structure that allows storing different data types in the same memory location.
d)
A data structure that organizes elements in a hierarchical tree-like structure.
5.
How to declare a double-pointer in C?
a)
int *val
b)
int **val
c)
int &val
d)
int *&val
6.

Which of the following is the correct way to declare a function in C?

a)

int functionName

b)

b) functionName int()

c)

c) int functionName()

d)

d) functionName() int

7.
What is the name of "&" operator in C?
a)

And

b)
And
c)
Address of
d)
None of the above
8.
Which of these is an exit-controlled loop?
a)
for
b)
if
c)
do…..while
d)
while
9.
Which operator is used to access the member of a structure?
a)
-
b)
>
c)
,
d)
.
10.
The size of a union is ___
a)
Sum of sizes of all members
b)
Predefined by the compiler
c)
Equal to size of largest data type
d)
None of these
11.
 Which function is used to open a file in C?
a)
open()
b)
fopen()
c)
file_open()
d)
fileopen()
12.
Which is the correct syntax to declare a file pointer in C?
a)
File *file_pointer;
b)
FILE *file_pointer;
c)
File file_pointer;
d)
FILE *file_pointer;
13.
What is CPP in C programming?
a)
C processing platform
b)
C PreProcessor
c)
C pre-platform
d)
None of these
14.

What will be the output of the following program?

#include<stdio.h>  int main() {  

int i;  int j = 2;  

for(i=1; i<=j; i++){ 

printf("%d", ++i);  } 

return 0;  }

a)

1

b)

3

c)

2

d)

0

15.
Which of the following is true about functions in C?
a)
Functions cannot return values
b)
Functions cannot accept arguments
c)
Functions help in code reusability and modularity
d)
Functions cannot be called recursively
16.
What is the syntax for defining a function in C?
a)
return_type function_name(parameters) {}
b)
function_name(parameters) return_type {}
c)
parameters return_type function_name {}
d)
function_name {} parameters return_type
17.
What is the return type of a function that does not return any value in C?
a)
int
b)
void
c)
char
d)
float
18.
What is the keyword used to define a structure in C?
a)
struct
b)
structure
c)
str
d)
class
19.
Which of the following is true about structures in C?
a)
A structure can contain variables of different data types
b)
A structure can only contain variables of the same data type
c)
Structures cannot be passed as arguments to functions
d)
Structures cannot be initialized at the time of declaration
20.

Predict the output:

#include <stdio.h>

struct Point {

int x,y; };

int main() {

struct Point p;

p.x = 5;

p.y = 10;

printf("(%d, %d)", p.x, p.y);

return 0; }

a)
(0, 0)
b)
(5, 10)
c)
(10, 5)
d)
Compiler error
21.
What does the '*' operator do when used with pointers in C?
a)
Declares a pointer variable
b)
Retrieves the address of a variable
c)
Retrieves the value stored at a memory address
d)
Performs bitwise AND operation
22.
Which of the following correctly declares a pointer variable in C?
a)
int *ptr;
b)
ptr int;
c)
ptr int;
d)
int ptr;
23.

Predict the output:

#include <stdio.h>

int main() {

int x = 5;

int *ptr = &x;

printf("%p", ptr);

return 0;}

a)
Address of the pointer variable
b)
Address of the 'x' variable
c)
Value of the 'x' variable
d)
Compiler error
24.
Which of the following libraries is used for file handling in C programming?
a)
stdlib.h
b)
stdio.h
c)
string.h
d)
math.h
25.

What is the return type of the fopen() function in C?

a)

int

b)

char

c)

FILE *

d)

void

26.

Which mode is used to open a file for reading in C?

a)

"r"

b)

"w"

c)

"a"

d)

"rb"

27.

Which function is used to read data from a file in C?

a)

fread()

b)

fwrite()

c)

fscanf()

d)

fprintf()

28.

Which function is used to write data to a file in C?

a)

fread()

b)

fwrite()

c)

fscanf()

d)

fprintf()

29.

Which mode is used to open a file for both reading and writing in C?

a)

"r+"

b)

"w+"

c)

"a+"

d)

"rw"

30.

Predict the output:

#include <stdio.h> 

int main() {

    int arr[] = {1, 2, 3, 4, 5};

    int *ptr = arr + 2;

    printf("%d", *ptr);

    return 0;}

a)

1

b)

2

c)

3

d)

Compiler error

31.

Which of the following correctly declares a pointer to an array in C?

a)

int ptr[];

b)

ptr int[];

c)

int *ptr[];

d)

int (*ptr)[];

32.

Which of the following is not a valid function declaration in C?

a)

int sum(int a, int b);

b)

void multiply(float x, float y);

c)

average(int[], int);

d)

float product(float, float);

33.

Which of the following is true about function parameters in C?

a)

Parameters are optional

b)

Parameters cannot have default values

c)

Parameters are variables used to pass values to a function

d)

Parameters can only be of type int