WorksheetsExploring the Basics of C Programming
Total questions: 20
Worksheet time: 10mins
What are the basic data types available in C?
string
int, float, double, char, void
array
boolean
How do you declare an integer variable in C?
int myVariable;
var myVariable;
integer myVariable;
float myVariable;
What is the purpose of preprocessor directives in C?
The purpose of preprocessor directives in C is to provide instructions to the compiler for file inclusion, macro definitions, and conditional compilation.
To manage memory allocation during execution.
To define the data types used in the program.
To optimize the runtime performance of the program.
Name one commonly used preprocessor directive in C.
#include
#ifdef
#endif
#define
Who developed the C programming language?
Dennis Ritchie
Linus Torvalds
James Gosling
Bjarne Stroustrup
In which year was the C programming language created?
1970
1990
1972
1985
What is an algorithm in the context of programming?
An algorithm is a step-by-step procedure for solving a problem or performing a task in programming.
An algorithm is a programming language.
An algorithm is a type of software application.
An algorithm is a hardware component used in computers.
How does a flowchart help in programming?
A flowchart eliminates the need for coding entirely.
A flowchart helps in programming by providing a visual representation of the program's logic and flow, aiding in understanding, debugging, and communication.
A flowchart is used to store data in a database.
A flowchart only serves as a decorative element in programming.
What is the size of the 'char' data type in C?
1.5 bytes
4 bytes
2 bytes
1 byte
What is the difference between 'int' and 'float' data types?
'int' can store decimal values while 'float' cannot.
Both 'int' and 'float' can only store whole numbers.
The difference is that 'int' is for whole numbers and 'float' is for numbers with decimals.
'int' is used for text data and 'float' for numeric data.
What does the '#include' directive do in a C program?
The '#include' directive defines a function in a C program.
The '#include' directive initializes variables in a C program.
The '#include' directive includes the contents of a file in a C program.
The '#include' directive compiles the program into an executable.
What is the significance of the 'main' function in C?
The 'main' function is where all functions are defined.
The 'main' function is used for variable declaration.
The 'main' function is the entry point of a C program.
The 'main' function is responsible for memory management.
Can you explain what a flowchart symbol for 'process' looks like?
An oval.
A diamond.
A circle.
A rectangle.
What is the output of the following code: 'printf("%d", 5 + 3);'?
10
9
8
6
What is the role of comments in C programming?
Comments can only be used in header files.
Comments are used to execute code faster.
Comments are mandatory for all functions in C.
Comments help document code and improve readability.
What is the output of the following code: 'printf("%f", 5.0 / 2);'?
2
3.0
2.5
2.0
Which of the following is a valid way to define a constant in C?
const int x = 10;
None of the above
Both of the above
#define x 10
What is the output of the following code: 'printf("%d", 10 - 4);'?
7
4
5
6
What is the purpose of the 'sizeof' operator in C?
To compare two variables.
To allocate memory dynamically.
To convert data types.
To determine the size of a variable or data type in bytes.
Which of the following correctly declares a floating-point variable in C?
double myVar;
float myVar;
number myVar;
decimal myVar;
