WorksheetsClassQuiz1
Total questions: 25
Worksheet time: 12mins
What is a computer program?
A set of instructions that a computer follows.
A type of hardware.
A programming language.
A software application.
What is the purpose of main() function in a C program?
Defines the program's name.
starting point of execution of the code.
Prints output to the console.
Declares variables.
What is the purpose of a semicolon in C?
To start a statement.
To end a statement.
To separate statements.
To declare a variable.
What is the output of printf("%d", 5 + 3);
5 + 3
8
53
Error
What does return 0 typically indicate at the end of a `main` function?
An error occurred.
Successful program execution.
The program should continue running.
The program is incomplete.
What does scanf("%d", &x); do?
Prints the value of x.
Reads an integer from the user and stores it in x.
Declares a variable x.
Calculates the value of x.
Which of these is a logical AND operator?
||
&&
!
=
Which operator is used for assigning a value to a variable?
=
==
+
-
What does the `%d` format specifier do in `printf`?
Prints a floating-point number.
Prints a character.
Prints an integer.
Prints a string.
What will the following code print: `printf("%d", 10 / 3);`?
3.333...
3
0
Error
What is an algorithm?
A programming language.
A set of steps to solve a problem.
A type of computer hardware.
A software application.
What is the purpose of a header file (e.g., stdio.h)?
Stores the main program logic.
Contains declarations of prebuilt functions.
Stores the program's data.
Contains the compiled code.
Which of the following is a valid C identifier?
1st_name
my-variable
_myVariable
int
What is the purpose of a keyword in C?
To define user-defined functions.
To declare variables.
To reserve words with special meaning to the compiler.
To name data types.
What is a variable in C programming?
A constant value.
A named storage location.
A function.
A data type.
Which format specifier is used to print a floating-point number in C?
%c
%d
%f
%s
What is the purpose of the `&` operator in `scanf`?
It represents the address of the variable.
It performs addition.
It performs bitwise AND operation.
It is a modulo operator.
What is the result of `printf("%f", 5.0/2.0);`?
2
2.5
2.0
2.500000
Which operator is used for equality comparison in C?
=
==
!=
<=
What does the ++ operator do?
Decrements a value by 1
Increments a value by 1
Multiplies a value by 2
Divides a value by 2
What is a nested 'if-else' statement?
An 'if' statement inside another 'if' statement.
An 'else' statement inside an 'if' statement.
Multiple 'if' statements in a row.
An 'if' statement followed by an 'else if' statement.
If a condition in an `if` statement evaluates to 0, it is considered:
True
False
An error
Undefined
Which Loop Structure is shown in the flowchart?
While
do-while
For loop
none
In a loop, it is mandatory either to increase or decrease the value loop control variable.
True
False
Identify the correct option that should correctly fill the blanks.
n and sum
sum += n and sum
sum -= n and n
n += 1 and n
