Font size
WorksheetsCIT-114 Introduction to computer Programming
Total questions: 25
Worksheet time: 13mins
Which language is known for its ability to handle complex tasks with minimal code?
Assembly
Python
C
JavaScript
Which is the correct syntax to include a header file in a C++ program?
#include<iostream>
#include "iostream"
#include iostream
Both A and B
What does the grammar syntax of programming languages ensure?
Vague interpretation
Flexibility
Correct interpretation of instruction
Non-standard instructions
What type of instructions can be written to a machine compared to a human?
Vague and context dependent
Precise and step by step
Flexible and general
Implied and interpretive
What is the purpose of using curly braces {} in an if-else statement?
To declare variables
To group multiple statements
To initialize an array
To create a function
Which of the following is the correct declaration of a float variable?
float num;
int num;
double num;
decimal num;
Which of the following is the correct way to read an integer from the keyboard in C++?
cin >> integerVariable;
cin.read(integerVariable);
read >> integerVariable;
input integerVariable;
Which of the following keywords is used to define a function in C++?
function
method
def
void
What is the output of the following code snippet: cout << 5 + 3 * 2;?
16
11
8
10
What will be the output of the following code snippet: cout << 10 / 2 + 3;?
7
8
5
6
What will be the output of the following code snippet: cout << 15 % 4 + 2;?
3
7
6
5
What is the output of the following code snippet: cout << (3 + 2) * 2;?
6
5
10
8
What is the primary difference between signed and unsigned data types?
Signed type can hold only positive values.
Unsigned type can hold both positive and negative values.
Unsigned type can only hold positive values.
There is no difference; they are the same.
What is the purpose of the assignment operator = in C++?
To compare two values
To perform an arithmetic operation
To assign a value to a variable
To declare a variable
How do parentheses affect expressions in C++?
They have no effect
They always cause an error
They determine the order of operations
They only affect arithmetic operations
Which of the following is a valid way to declare a constant in C++?
#define x 10
let x = 10;
const int x = 10;
constant int x = 10;
What is the purpose of the switch statement in C++?
To compare two values
To execute a block of code among multiple options based on a variable's value
To create a loop
To handle exceptions
Which of the following is a correct syntax for an if statement in C++?
if(Condition){statement;}
if(Condition) statement;
if Condition {statement;}
Both A and B
What does the for loop do in C++?
Repeats a block of code a specified number of times
Checks a condition and executes code if it's true
Defines a function
None of the above
Why do computers require exact instructions?
To enhance flexibility
To ensure precision and correctness
To allow ambiguity
To simplify hardware design
Which of the following is used to create a loop that executes at least once in C++?
while loop
for loop
foreach loop
do-while loop
What is the purpose of the break statement in C++?
To exit a loop or switch statement
To pause the execution
To skip the current iteration
To terminate the program
what is your computer classified as in term of computing?
Specific purpose device
General purpose computing device
Static device
Non computational device
Which device requires exact setting such as timer and water level for operation?
Human
Microwave
Washing machine
Calculator
What happens if the user enters a non integer value when reading an integer in C++
The program will terminate
To value will be stored as zero
It will cause an infinite loop
The input will fail and the variable remains unchanged
