wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

ByteBattle2.0(C)

Total questions: 30

Worksheet time: 23mins

Name
Class
Date
1.

What is the extension of C programming files?

a)

.txt

b)

.c

c)

.cpp

d)

.java

2.

Which function is used to display output in C?

a)

print()

b)

System.out.println()

c)

cout

d)

printf()

3.

Which symbol is used to end a statement in C?

a)

:

b)

.

c)

;

d)

,

4.

Which of the following is a valid variable declaration in C?

a)

int 1num

b)

int num1;

c)

int #num;

d)

int num ;

5.

What is the correct syntax for a main function in C?

a)

int main()

b)

void main()

c)

main()

d)

public main()

6.

What will the following code print? printf("Hello, World!");

a)

Hello

b)

World

c)

Hello, World!

d)

Error

7.

Which of the following is a valid comment in C?

a)

# This is a comment

b)

// This is a comment

c)

/* This is a comment */

d)

Both b) and c)

8.

What is the purpose of the return 0; statement in the main function?

a)

To terminate the program

b)

To indicate successful program completion

c)

To print the value 0

d)

To declare a variable

9.

Which of the following is a valid if statement in C?

a)

if (x = 10)

b)

if (x == 10)

c)

if x == 10:

d)

if (x 10)

10.

Which function is used to take input from the user in C?

a)

printf()

b)

scanf()

c)

cin

d)

gets()

11.

What is the correct syntax to declare an integer variable in C?

a)

int a;

b)

integer a;

c)

int a[];

d)

int a(10);

12.

What will the following code print? int a = 10; printf("%d", a);

a)

10

b)

0

c)

a

d)

Compilation error

13.

Which of the following is not a valid C keyword?

a)

int

b)

float

c)

char

d)

string

14.

What is the result of 5 + 2 * 3 in C?

a)

21

b)

11

c)

16

d)

7

15.

Which operator is used to assign a value to a variable?

a)

=

b)

==

c)

+=

d)

&

16.

What is the result of the following code? int a = 5; a++; printf("%d", a);

a)

5

b)

6

c)

4

d)

Compilation error

17.

Which data type can store a decimal number?

a)

int

b)

char

c)

float

d)

void

18.

Which of the following is a relational operator in C?

a)

+

b)

*

c)

>

d)

=

19.

What is the correct syntax to declare an array in C?

a)

int arr[5];

b)

array int arr[5];

c)

arr int[5];

d)

int[] arr;

20.

Which of the following is a valid format specifier for an integer in C?

a)

%d

b)

%f

c)

%s

d)

%c

21.

Which of the following is used to terminate a loop in C?

a)

exit

b)

break

c)

continue

d)

return

22.

What is the output of the following code? int a = 5, b = 10; printf("%d", a + b);

a)

10

b)

5

c)

15

d)

Compilation error

23.

Which of the following loops is used when the number of iterations is known?

a)

for loop

b)

while loop

c)

do-while loop

d)

goto loop

24.

Which function is used to calculate the length of a string in C?

a)

strlen()

b)

strcat()

c)

strcmp()

d)

scanf()

25.

What is the purpose of the continue statement in C?

a)

To stop the loop

b)

To skip the current iteration and move to the next one

c)

To end the program

d)

To declare a variable

26.

Which data type is used to store a single character in C?

a)

char

b)

string

c)

int

d)

float

27.

What is the result of 10 / 3 in C?

a)

3.33

b)

3

c)

4

d)

Compilation error

28.

what will be the output of following code?
int a=10;
printf(if(a==10));

a)

-1

b)

error

c)

1

d)

0

29.

What is the output of the following code? int a = 5; if (a > 0) printf("Positive"); else printf("Negative");

a)

Positive

b)

Negative

c)

Error

d)

5

30.

Which of the following operators is used for logical AND in C?

a)

&

b)

&&

c)

||

d)

!