WorksheetsProgramming Languages Quiz
Total questions: 93
Worksheet time: 47mins
Why do we need high-level programming languages?
They are easier for humans to understand and write.
They are more difficult for computers to process.
They are less efficient than machine code.
They are only used for specific applications.
What is one disadvantage of writing machine code directly?
It is faster to write.
It is error-prone.
It is more secure.
It is easier to debug.
What is a consequence of each computer architecture having its own machine code format?
Increased compatibility between systems
Incompatibility between systems
Faster processing speeds
Reduced need for programming languages
What is a proposed solution to the incompatibility caused by diverse machine code formats?
Use low-level programming languages
Use high-level programming languages
Create a universal machine code
Eliminate machine code entirely
What is the role of a compiler in programming?
It translates machine code into human-readable code.
It translates human-readable code into machine code.
It directly executes high-level language code.
It stores data for programs.
Which compiler is most commonly used for C programming?
JDK
LLVM
GCC
MSVC
Why can't computers understand high-level languages directly?
They require more memory.
They are designed to only process machine code.
High-level languages are too complex.
They need an interpreter for high-level languages.
Why is the C language widely used?
It has a complex syntax.
It is only used for web development.
It has readable syntax and portability.
It does not require compilation.
In what type of files are C programs written?
.java files
.py files
.c files
.html files
What is necessary to execute C code?
Interpretation
Compilation
Direct execution
Scripting
What command is used to compile C code?
g++
gcc
javac
python
What is a key consideration when using the gcc command across different operating systems?
The syntax changes completely
The installation process differs
The command is not available on Windows
The output file format changes
Which of the following is an example of a gcc command to compile a file named program.c?
gcc program.c -o program
compile program.c -o program
gcc -compile program.c
gcc program.c -output program
What is the purpose of the `main` function in a C program?
To perform input operations
To define the starting point of the program
To handle errors
To include libraries
Which function is used for output in a C program?
scanf
printf
main
return
What does `return 0;` signify in a C program?
The program has failed
The program is paused
The program has executed successfully
The program is restarting
What library is included at the beginning of a basic C program?
What is the first step in compiling and running a C program?
Compile with gcc
Run the executable
Save code into a file
Debug the code
Which command is used to compile a C program in the given example?
gcc C:/Users/hello.c -o C:/Users/hello.exe
run C:/Users/hello.exe
save C:/Users/hello.c
execute C:/Users/hello.exe
What is the final step to execute the compiled C program?
Compile with gcc
Save code into a file
Run the executable
Debug the code
What is the first step in compiling and running a C program?
Compile the code
Run the executable
Save the code into a file
Debug the code
Which command is used to compile a C program using gcc?
gcc hello.c -o hello
run hello
execute hello
compile hello.c
What is the command to run the executable after compiling a C program?
./run
./execute
./hello
./start
What does a relative path refer to in command line basics?
Path from the root directory
Path relative to the current directory
Path to the home directory
Path to the system directory
Which command is used to change directories in the command line?
ls
mv
cd
rm
What does the symbol '.' represent in command line navigation?
Root directory
Current directory
Parent directory
Home directory
What does the symbol '..' represent in command line navigation?
Root directory
Current directory
Parent directory
Home directory
What is an absolute path in command line terminology?
Path from the current directory
Path from the root directory
Path to the home directory
Path to the system directory
What is generated after the compilation of a program?
Source code
Executable file
Text document
Script file
What does the './' indicate when running a compiled program?
The file is a script
The file is in the root directory
The executable is in the current directory
The file is hidden
Which data type in C is used to store integer values?
float
char
int
double
What data type would you use in C to store a single character?
int
float
char
double
In C, which data types are used to store decimal numbers?
int and char
float and double
char and int
double and char
What is the correct way to declare a float variable named 'height' with a value of 1.75 in C?
int height = 1.75;
float height = 1.75;
char height = 1.75;
double height = 1.75;
Which of the following is a correct way to assign a character literal in C++?
char c = "A";
char c = 'A';
char c = A;
char c = 65;
What is the correct way to assign a float literal in C++?
float pi = 3.14;
float pi = '3.14';
float pi = "3.14";
float pi = 3;
Identify the mistake in the following code: int num = 3.14;
The variable type should be float.
The number should be enclosed in quotes.
The semicolon is missing.
The variable name is incorrect.
Which format specifier is used for an integer in printf?
%f
%d
%c
%s
What is the output of the following printf statement: printf("Age: %d, Height: %.2f\n", 20, 1.75);?
Age: 20, Height: 1.750
Age: 20, Height: 1.75
Age: 20, Height: 1.7
Age: 20, Height: 1.7500
Which format specifier is used for a string in printf?
%d
%f
%s
%c
In printf, what does the format specifier %f represent?
Integer
Character
String
Float/Double
Which function is used in C to take input from the user?
printf
scanf
input
get
In the example provided, what data type is used for the variable 'age'?
float
char
int
double
What is the purpose of the '&' symbol in the scanf function?
It specifies the data type.
It indicates the variable's address.
It is used to print the variable.
It is a placeholder for input.
What is the purpose of the `scanf` function in the provided C code example?
To print data to the console
To read formatted input from the user
To declare variables
To end the program
Which data type is used to store the height in the provided C code example?
int
char
float
double
In the provided C code example, what does the `printf` function do?
It reads input from the user
It prints formatted output to the console
It declares variables
It ends the program
What function is used to take multiple inputs from the user at once in C programming?
printf
scanf
gets
puts
In the example provided, which data type is used for the variables math, english, and physic?
int
double
float
char
What is the correct format specifier used in the scanf function to read float values?
%d
%c
%s
%f
In the example, how are the variables passed to the scanf function?
By value
By reference
As constants
As strings
Why do computers require compilers?
To understand binary
To execute programs faster
To convert high-level code to binary
To store data efficiently
Which command is used to compile C programs?
gcc
g++
javac
python
What is one of the topics explored in the learning material?
Advanced machine learning algorithms
Writing, compiling, and running C code
History of programming languages
Web development basics
What do data types define in a variable?
The kind of data a variable can store
The speed of data processing
The color of the data
The location of data storage
Which of the following is NOT determined by data types?
Memory size
Range of values
Valid operations
Network speed
Which of the following is an integer type?
float
char
double
string
Which category does the 'double' data type belong to?
Integer types
Floating-point types
Character types
Boolean types
What is the main difference between signed and unsigned types?
Signed types can only represent positive values.
Unsigned types can represent both negative and positive values.
Signed types can represent both negative and positive values.
Unsigned types can represent negative values.
Which of the following is true about unsigned types?
They can represent negative values.
They can only represent positive values, including zero.
They have a smaller positive range than signed types.
They can represent both negative and positive values.
Given the code snippet below, what is the value of 'a'?
10
-10
0
20
What is the size of a char type in C?
2 bytes (usually 16 bits)
1 byte (usually 8 bits)
4 bytes (usually 32 bits)
8 bytes (usually 64 bits)
What is the range of a signed char type in C?
0 to 255
-128 to 127
-256 to 255
0 to 127
What is the range of an unsigned char type in C?
0 to 127
-128 to 127
0 to 255
-255 to 255
Which format specifier is used for a character in C?
%d
%f
%c
%s
Which of the following is a valid declaration of a char variable in C++?
char letter = 'A';
char digit = "9";
char wrong = 300;
char out = "A";
Why is the declaration `char wrong = "A";` considered invalid in C++?
It uses double quotes, which are for strings.
It exceeds the range of char.
It uses single quotes, which are for strings.
It is missing a semicolon.
What is the reason for the invalidity of the declaration `char out = 300;` in C++?
It uses double quotes.
It exceeds the range of char.
It uses single quotes.
It is missing a semicolon.
What is the size of the 'short' type on most systems?
1 byte (8 bits)
2 bytes (16 bits)
4 bytes (32 bits)
8 bytes (64 bits)
What is the range of a 'signed short' type?
-65,535 to 65,535
-32,768 to 32,767
0 to 32,767
0 to 65,535
What is the range of an 'unsigned short' type?
-32,768 to 32,767
0 to 32,767
0 to 65,535
-65,535 to 65,535
What is the format specifier for a 'short' integer?
%d
%f
%hd
%ld
What is the valid range of values for a 'short' data type in most programming languages?
-32,768 to 32,767
0 to 65,535
-128 to 127
0 to 255
Why is the assignment 'short wrong = 40000;' considered invalid?
It exceeds the maximum value for 'short'
It is a syntax error
'short' cannot store positive numbers
'short' requires a decimal value
What is the purpose of using 'unsigned short' in programming?
To allow negative values
To increase the maximum positive value
To store decimal numbers
To store characters
What is the size of an int type on most systems?
2 bytes (16 bits)
4 bytes (32 bits)
8 bytes (64 bits)
1 byte (8 bits)
What is the range of a signed int type?
0 to 4,294,967,295
-2,147,483,648 to 2,147,483,647
-1,073,741,824 to 1,073,741,823
0 to 2,147,483,647
What is the range of an unsigned int type?
-2,147,483,648 to 2,147,483,647
0 to 2,147,483,647
0 to 4,294,967,295
-1,073,741,824 to 1,073,741,823
Which format specifier is used for an int type in C?
%f
%c
%d or %i
%s
Which of the following is a valid declaration of an integer variable in C++?
int score = 100;
int score = 3.14;
int score = "100";
int score = true;
Why is the declaration `int invalid = 3.14;` considered invalid in C++?
Because 3.14 is a string.
Because 3.14 is a boolean.
Because 3.14 is a float.
Because 3.14 is a character.
What is the purpose of using `unsigned int` in C++?
To store negative numbers.
To store floating-point numbers.
To store only positive numbers.
To store characters.
What is the size of a 'long' type variable in bytes, depending on the system?
2 or 4 bytes
4 or 8 bytes
8 or 16 bytes
1 or 2 bytes
What is the approximate range of a signed 'long' type variable for 8 bytes?
-9.2e18 to 9.2e18
-4.6e18 to 4.6e18
-1.8e18 to 1.8e18
-2.3e18 to 2.3e18
What is the range of an unsigned 'long' type variable for 8 bytes?
0 to 9.2e18
0 to 18.4e18
0 to 4.6e18
0 to 1.8e18
Which format specifier is used for an unsigned 'long' type in C?
%ld
%lu
%lf
%lx
Which of the following is a valid declaration of a long integer in programming?
long population = 7800000000;
unsigned long big = 4000000000;
long wrong = "hello";
long number = "12345";
Why is the declaration `long wrong = "hello";` considered invalid?
Because "hello" is not a number
Because long cannot store strings
Because it lacks a semicolon
Because it uses an incorrect data type
What is the purpose of using `unsigned long` in a variable declaration?
To store negative numbers
To store larger positive numbers
To store decimal numbers
To store characters
What is the size of the float type in bytes?
2 bytes
4 bytes
8 bytes
16 bytes
What is the approximate range of values for the float type?
1.2E-10 to 3.4E+10
1.2E-20 to 3.4E+20
1.2E-38 to 3.4E+38
1.2E-50 to 3.4E+50
How many decimal digits of precision does the float type approximately have?
5 decimal digits
7 decimal digits
10 decimal digits
15 decimal digits
What is the format specifier used for the float type?
%d
%c
%f
%s
