Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Exploring the Basics of C Programming

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What are the basic data types available in C?

a)

string

b)

int, float, double, char, void

c)

array

d)

boolean

2.

How do you declare an integer variable in C?

a)

int myVariable;

b)

var myVariable;

c)

integer myVariable;

d)

float myVariable;

3.

What is the purpose of preprocessor directives in C?

a)

The purpose of preprocessor directives in C is to provide instructions to the compiler for file inclusion, macro definitions, and conditional compilation.

b)

To manage memory allocation during execution.

c)

To define the data types used in the program.

d)

To optimize the runtime performance of the program.

4.

Name one commonly used preprocessor directive in C.

a)

#include

b)

#ifdef

c)

#endif

d)

#define

5.

Who developed the C programming language?

a)

Dennis Ritchie

b)

Linus Torvalds

c)

James Gosling

d)

Bjarne Stroustrup

6.

In which year was the C programming language created?

a)

1970

b)

1990

c)

1972

d)

1985

7.

What is an algorithm in the context of programming?

a)

An algorithm is a step-by-step procedure for solving a problem or performing a task in programming.

b)

An algorithm is a programming language.

c)

An algorithm is a type of software application.

d)

An algorithm is a hardware component used in computers.

8.

How does a flowchart help in programming?

a)

A flowchart eliminates the need for coding entirely.

b)

A flowchart helps in programming by providing a visual representation of the program's logic and flow, aiding in understanding, debugging, and communication.

c)

A flowchart is used to store data in a database.

d)

A flowchart only serves as a decorative element in programming.

9.

What is the size of the 'char' data type in C?

a)

1.5 bytes

b)

4 bytes

c)

2 bytes

d)

1 byte

10.

What is the difference between 'int' and 'float' data types?

a)

'int' can store decimal values while 'float' cannot.

b)

Both 'int' and 'float' can only store whole numbers.

c)

The difference is that 'int' is for whole numbers and 'float' is for numbers with decimals.

d)

'int' is used for text data and 'float' for numeric data.

11.

What does the '#include' directive do in a C program?

a)

The '#include' directive defines a function in a C program.

b)

The '#include' directive initializes variables in a C program.

c)

The '#include' directive includes the contents of a file in a C program.

d)

The '#include' directive compiles the program into an executable.

12.

What is the significance of the 'main' function in C?

a)

The 'main' function is where all functions are defined.

b)

The 'main' function is used for variable declaration.

c)

The 'main' function is the entry point of a C program.

d)

The 'main' function is responsible for memory management.

13.

Can you explain what a flowchart symbol for 'process' looks like?

a)

An oval.

b)

A diamond.

c)

A circle.

d)

A rectangle.

14.

What is the output of the following code: 'printf("%d", 5 + 3);'?

a)

10

b)

9

c)

8

d)

6

15.

What is the role of comments in C programming?

a)

Comments can only be used in header files.

b)

Comments are used to execute code faster.

c)

Comments are mandatory for all functions in C.

d)

Comments help document code and improve readability.

16.

What is the output of the following code: 'printf("%f", 5.0 / 2);'?

a)

2

b)

3.0

c)

2.5

d)

2.0

17.

Which of the following is a valid way to define a constant in C?

a)

const int x = 10;

b)

None of the above

c)

Both of the above

d)

#define x 10

18.

What is the output of the following code: 'printf("%d", 10 - 4);'?

a)

7

b)

4

c)

5

d)

6

19.

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

a)

To compare two variables.

b)

To allocate memory dynamically.

c)

To convert data types.

d)

To determine the size of a variable or data type in bytes.

20.

Which of the following correctly declares a floating-point variable in C?

a)

double myVar;

b)

float myVar;

c)

number myVar;

d)

decimal myVar;