wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C Programming Fundamentals

Total questions: 16

Worksheet time: 8mins

Name
Class
Date
1.

What is the correct syntax to include a header file in C?

a)

#include

b)

#include {header_file.h}

c)

d)

import header_file.h

2.

Explain the purpose of the main() function in a C program.

a)

The main() function is used for defining global variables.

b)

The main() function is where all the functions are declared.

c)

The main() function handles memory allocation in a C program.

d)

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

3.

What is the difference between a variable and a constant in C?

a)

A variable can change its value, while a constant cannot.

b)

A variable is used for functions, while a constant is used for loops.

c)

Both variables and constants can change their values.

d)

A variable is a fixed value, while a constant can change.

4.

How do you declare an integer variable in C?

a)

integer myVariable;

b)

var myVariable;

c)

float myVariable;

d)

int myVariable;

5.

What is a function prototype in C?

a)

A function prototype is the actual implementation of a function.

b)

A function prototype is a type of variable used in C programming.

c)

A function prototype is a declaration of a function that specifies its name, return type, and parameters.

d)

A function prototype is a comment describing a function's purpose.

6.

How do you define a function in C?

a)

function_name(parameter_name) return_type { // function body }

b)

return_type function_name(parameter_type parameter_name) { // function body }

c)

function_name(parameter_type) { // function body }

d)

return_type function_name { // function body }

7.

What is the return type of a function that does not return a value?

a)

float

b)

string

c)

void

d)

int

8.

Explain the concept of recursion in C functions.

a)

Recursion is when a function runs in parallel with another function.

b)

Recursion is a programming technique where a function calls itself to solve smaller instances of the same problem, requiring a base case to stop the recursion.

c)

Recursion is a technique where a function calls another function to perform tasks.

d)

Recursion is a method of optimizing code by removing loops.

9.

What is an array in C?

a)

An array in C is a collection of different types stored randomly in memory.

b)

An array in C is a single element of any type.

c)

An array in C is a collection of elements of the same type stored in contiguous memory locations.

d)

An array in C is a function that returns multiple values.

10.

How do you access the elements of an array in C?

a)

Use the array subscript operator [] with the index of the element.

b)

Use the parentheses () to index the array.

c)

Use the dot operator . to access elements.

d)

Access elements using the array name only.

11.

What is a pointer in C?

a)

A pointer is a type of function in C.

b)

A pointer is a variable that holds the address of another variable in C.

c)

A pointer is a variable that stores a string in C.

d)

A pointer is a special kind of loop in C.

12.

How do you declare a pointer variable in C?

a)

pointer int *ptr;

b)

int ptr;

c)

int *ptr;

d)

int &ptr;

13.

What is the difference between an array and a pointer?

a)

An array can change size dynamically, while a pointer cannot.

b)

A pointer is a collection of elements, while an array is a single variable.

c)

An array holds the address of a variable, while a pointer holds the value of an element.

d)

An array is a fixed-size collection of elements, while a pointer is a variable that holds the address of another variable.

14.

Define a structure in C and give an example.

a)

struct Rectangle { int length; int width; };

b)

struct Circle { float radius; };

c)

struct Point { int x; int y; };

d)

struct Line { int start; int end; };

15.

How do you access members of a structure in C?

a)

Access members using the colon operator (:).

b)

Use the semicolon (;) for structure variables.

c)

Use the asterisk (*) for structure pointers.

d)

Use the dot operator (.) for structure variables and the arrow operator (->) for pointers.

16.

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

a)

To allocate memory for a variable at runtime.

b)

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

c)

To calculate the total number of variables in a program.

d)

To convert a data type to a string representation.