wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Computer Science Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is an array in programming?

a)

C. A data structure that can only store integers

b)

D. A type of loop in programming

c)

B. A fixed-size sequenced collection of elements of the same data type

d)

A. A variable that can store multiple data types

2.

How can arrays be initialized?

a)

D. Arrays cannot be initialized

b)

B. Only at run time

c)

A. Only at compile time

d)

C. Both at compile time and run time

3.

What is the difference between character arrays and strings?

a)

B. Character arrays are stored in the String Constant Pool

b)

A. Character arrays are immutable, strings are mutable

c)

D. Character arrays have built-in methods to perform operations

d)

C. Strings can be converted to character arrays using toCharArray() method

4.

What is the syntax for defining a function with arguments and return value?

a)

D. int function()

b)

C. void function()

c)

B. int function(int x)

d)

A. void function(int x)

5.

What is the purpose of the checkPrimeNumber function in the C program?

a)

D. To convert a string to a character array

b)

C. To calculate the Fibonacci series

c)

B. To check if a number is prime

d)

A. To swap two integers

6.

What is the difference between Call by Value and Call by Reference?

a)

C. Call by Value allows altering the values of actual variables

b)

B. Call by Reference copies the values of variables

c)

A. Call by Value uses pointer variables

d)

D. Call by Reference is preferred for passing small values

7.

What is recursion in programming?

a)

A. The process of repeating items in a self-similar way

b)

B. The process of swapping variables

c)

C. The process of converting strings to arrays

d)

D. The process of defining multiple functions

8.

How can arrays be passed to a function?

a)

B. Only as a sized array

b)

A. Only as a pointer

c)

C. Only as an unsized array

d)

D. All of the above

9.

What is the output of the Fibonacci program in the C code?

a)

A. 0 1 1 2 3 5 8 13 21 34

b)

D. 1 3 5 7 9 11 13 15 17 19

c)

B. 1 2 3 5 8 13 21 34 55 89

d)

C. 0 1 1 2 3 5 8 13 21 29

10.

What is the purpose of the Strfun function in the C program?

a)

D. To define a recursive function

b)

C. To calculate prime numbers

c)

B. To pass a string to a function

d)

A. To declare a buffer of type char

11.

When is Call by Value preferred over Call by Reference?

a)

D. When using pointer variables

b)

A. When passing a large amount of data

c)

B. When altering the values of variables

d)

C. When passing small values that should not change

12.

What is the purpose of the getchar function in programming?

a)

A. To check if a number is prime

b)

C. To store passwords in character arrays

c)

D. To return an integer representing a character

d)

B. To convert a string to a character array

13.

What is the general form of initializing arrays at compile time?

a)

C. void function(int x)

b)

D. int j, flag = 1

c)

B. int n1, n2, i, flag

d)

A. float total[5] = {0.0,15.75,-10}

14.

What is the purpose of the C program to display prime numbers between intervals?

a)

C. To check if a number is prime

b)

D. To pass strings to a function

c)

B. To calculate the Fibonacci series

d)

A. To swap two positive integers

15.

What is the difference between one dimensional arrays and character arrays?

a)

D. One dimensional arrays have built-in methods to perform operations

b)

C. Character arrays can be converted into strings

c)

B. One dimensional arrays are stored in the Heap

d)

A. One dimensional arrays are mutable, character arrays are immutable