wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Round_1 (B)| Coding Combat 2.0

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

What is the syntax to declare a variable in C?

a)

variableType variableName;

b)

var variableName;

c)

variableName = value;

d)

nt variableName;

2.

Who is the father of C language?

a)

Steve Jobs

b)

James Gosling

c)

Dennis Ritchie

d)

Rasmus Lerdorf

3.

Which of the following is not a valid C variable name?

a)

int number;

b)

float rate;

c)

int variable_count;

d)

int $main;

4.

What is the output of the following C code snippet?

int x = 5;
int y = 10;
int z = x + y;
printf("%d", z);

a)

15

b)

10

c)

5

d)

20

5.

Which header file is used for input and output functions in C?

a)

stdio.h

b)

math.h

c)

stdlib.h

d)

string.h

6.

What is the purpose of the 'break' statement in C?

a)

To exit the loop immediately

b)

To skip the current iteration and move to the next

c)

To define a case in switch statement

d)

To continue the loop from the beginning

7.

Which of the following is true for variable names in C?

a)

They can contain alphanumeric characters as well as special characters

b)

It is not an error to declare a variable to be one of the keywords(like goto, static)

c)

Variable names cannot start with a digit

d)

Variable can be of any length

8.


What will be the output of the following code snippet?

#include <stdio.h> int main() { int a = 3, b = 5; int t = a; a = b; b = t; printf("%d %d", a, b); return 0; }

a)

3.5

b)

3.3

c)

5.5

d)

5.3

9.

What is the purpose of the 'continue' statement in C?

a)

To exit the loop immediately

b)

To skip the current iteration and move to the next

c)

To define a case in switch statement

d)

To restart the loop from the beginning

10.

Which of the following is true for functions in C?

a)

Functions cannot return values

b)

Functions can only be called once in a program

c)

Functions can be recursive

d)

Functions cannot have parameters

11.

What is the output of the following C code snippet?

int a = 10;
int b = 3;
int c = a % b;
printf("%d", c);

a)

3

b)

1

c)

0

d)

10

12.

What is the purpose of the 'void' keyword in C?

a)

To declare a function that does not return any value

b)

To declare a variable without assigning a value

c)

To define a constant value

d)

To specify the size of a data type

13.

Which operator is used for pointer dereferencing in C?

a)

&

b)

*

c)

->

d)

::

14.

What is the output of the following C code snippet?

int i = 5;
int j = 2;
float result = (float)i / j;
printf("%f", result);

a)

2.5

b)

2

c)

2.0

d)

2.2

15.

What is the purpose of the 'if' statement in C?

a)

To exit the loop immediately

b)

To skip the current iteration and move to the next

c)

To define a case in switch statement

d)

To conditionally execute a block of code

16.

What is the output of the following C code snippet?

int x = 7;
int y = 2;
int z = x / y;
printf("%d", z);

a)

3

b)

2

c)

3.5

d)

2.5

17.

What is the syntax to define a constant in C?

a)

const variableType constantName = value;

b)

constantType constantName = value;

c)

variableType constantName = value;

d)

constantName = value;

18.

Which of these is NOT a relational or logical operator?

a)

=

b)

||

c)

==

d)

!=

19.

What is the purpose of the 'sizeof' operator in C?

a)

To return the size of a variable or data type

b)

To perform addition operation

c)

To compare two variables

d)

To exit the loop immediately

20.

Which of the following is true for the 'switch' statement in C?

a)

It can only be used with integers

b)

It can only have one case

c)

It can have multiple cases with the same value

d)

It is used to define a function

21.

What is the output of the following C code snippet?

int a = 5;
int b = 2;
int c = a * b;
printf("%d", c);

a)

7

b)

10

c)

3

d)

12

22.

We cannot use the keyword ‘break’ simply within _________.

a)

while

b)

for

c)

if-else

d)

do-while

23.

What is the purpose of the 'do-while' loop in C?

a)

To execute a block of code repeatedly as long as the condition is true

b)

To execute a block of code only once

c)

To skip the current iteration and move to the next

d)

To define a case in switch statement

24.

What is the output of the following C code snippet?

int x = 8;
int y = 3;
int z = x - y;
printf("%d", z);

a)

5

b)

3

c)

8

d)

2

25.

Which of the following is true for arrays in C?

a)

Arrays can only store elements of the same data type

b)

Arrays can dynamically resize during runtime

c)

Arrays cannot be passed to functions

d)

Arrays cannot have more than 10 elements

26.

The correct format of declaring a function is:

a)

type_of_return name_of_function (argument type);

b)

type_of_return name_of_function (argument type){}

c)

type_of_return (argument type) name_of_function;

d)

all of the above

27.

What is the purpose of the 'while' loop in C?

a)

To execute a block of code repeatedly as long as the condition is true

b)

To execute a block of code only once

c)

To skip the current iteration and move to the next

d)

To define a case in switch statement

28.

What is the output of the following C code snippet?

int x = 4;
int y = 3;
int z = x % y;
printf("%d", z);

a)

1

b)

2

c)

0

d)

3

29.

Which of the following is true for the 'for' loop in C?

a)

It can only be used with integers

b)

It can only have one case

c)

It can have multiple cases with the same value

d)

It is used to define a function

30.

Which of these is the correct initialization method for the following:

typedef char *string;

a)

More than a single space shouldn’t be given when we are using typedef

b)

*string p = ‘A’;

c)

string p = “Hello”;

d)

*string p = “Hello”;