NEW
Font size
WorksheetsC Programming Fundamentals
Total questions: 16
Worksheet time: 8mins
What is the correct syntax to include a header file in C?
#include
#include {header_file.h}
import header_file.h
Explain the purpose of the main() function in a C program.
The main() function is used for defining global variables.
The main() function is where all the functions are declared.
The main() function handles memory allocation in a C program.
The main() function is the entry point of a C program.
What is the difference between a variable and a constant in C?
A variable can change its value, while a constant cannot.
A variable is used for functions, while a constant is used for loops.
Both variables and constants can change their values.
A variable is a fixed value, while a constant can change.
How do you declare an integer variable in C?
integer myVariable;
var myVariable;
float myVariable;
int myVariable;
What is a function prototype in C?
A function prototype is the actual implementation of a function.
A function prototype is a type of variable used in C programming.
A function prototype is a declaration of a function that specifies its name, return type, and parameters.
A function prototype is a comment describing a function's purpose.
How do you define a function in C?
function_name(parameter_name) return_type { // function body }
return_type function_name(parameter_type parameter_name) { // function body }
function_name(parameter_type) { // function body }
return_type function_name { // function body }
What is the return type of a function that does not return a value?
float
string
void
int
Explain the concept of recursion in C functions.
Recursion is when a function runs in parallel with another function.
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.
Recursion is a technique where a function calls another function to perform tasks.
Recursion is a method of optimizing code by removing loops.
What is an array in C?
An array in C is a collection of different types stored randomly in memory.
An array in C is a single element of any type.
An array in C is a collection of elements of the same type stored in contiguous memory locations.
An array in C is a function that returns multiple values.
How do you access the elements of an array in C?
Use the array subscript operator [] with the index of the element.
Use the parentheses () to index the array.
Use the dot operator . to access elements.
Access elements using the array name only.
What is a pointer in C?
A pointer is a type of function in C.
A pointer is a variable that holds the address of another variable in C.
A pointer is a variable that stores a string in C.
A pointer is a special kind of loop in C.
How do you declare a pointer variable in C?
pointer int *ptr;
int ptr;
int *ptr;
int &ptr;
What is the difference between an array and a pointer?
An array can change size dynamically, while a pointer cannot.
A pointer is a collection of elements, while an array is a single variable.
An array holds the address of a variable, while a pointer holds the value of an element.
An array is a fixed-size collection of elements, while a pointer is a variable that holds the address of another variable.
Define a structure in C and give an example.
struct Rectangle { int length; int width; };
struct Circle { float radius; };
struct Point { int x; int y; };
struct Line { int start; int end; };
How do you access members of a structure in C?
Access members using the colon operator (:).
Use the semicolon (;) for structure variables.
Use the asterisk (*) for structure pointers.
Use the dot operator (.) for structure variables and the arrow operator (->) for pointers.
What is the purpose of the 'sizeof' operator in C?
To allocate memory for a variable at runtime.
To determine the size, in bytes, of a data type or variable.
To calculate the total number of variables in a program.
To convert a data type to a string representation.
