wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Programming Languages Quiz

Total questions: 93

Worksheet time: 47mins

Name
Class
Date
1.

Why do we need high-level programming languages?

a)

They are easier for humans to understand and write.

b)

They are more difficult for computers to process.

c)

They are less efficient than machine code.

d)

They are only used for specific applications.

2.

What is one disadvantage of writing machine code directly?

a)

It is faster to write.

b)

It is error-prone.

c)

It is more secure.

d)

It is easier to debug.

3.

What is a consequence of each computer architecture having its own machine code format?

a)

Increased compatibility between systems

b)

Incompatibility between systems

c)

Faster processing speeds

d)

Reduced need for programming languages

4.

What is a proposed solution to the incompatibility caused by diverse machine code formats?

a)

Use low-level programming languages

b)

Use high-level programming languages

c)

Create a universal machine code

d)

Eliminate machine code entirely

5.

What is the role of a compiler in programming?

a)

It translates machine code into human-readable code.

b)

It translates human-readable code into machine code.

c)

It directly executes high-level language code.

d)

It stores data for programs.

6.

Which compiler is most commonly used for C programming?

a)

JDK

b)

LLVM

c)

GCC

d)

MSVC

7.

Why can't computers understand high-level languages directly?

a)

They require more memory.

b)

They are designed to only process machine code.

c)

High-level languages are too complex.

d)

They need an interpreter for high-level languages.

8.

Why is the C language widely used?

a)

It has a complex syntax.

b)

It is only used for web development.

c)

It has readable syntax and portability.

d)

It does not require compilation.

9.

In what type of files are C programs written?

a)

.java files

b)

.py files

c)

.c files

d)

.html files

10.

What is necessary to execute C code?

a)

Interpretation

b)

Compilation

c)

Direct execution

d)

Scripting

11.

What command is used to compile C code?

a)

g++

b)

gcc

c)

javac

d)

python

12.

What is a key consideration when using the gcc command across different operating systems?

a)

The syntax changes completely

b)

The installation process differs

c)

The command is not available on Windows

d)

The output file format changes

13.

Which of the following is an example of a gcc command to compile a file named program.c?

a)

gcc program.c -o program

b)

compile program.c -o program

c)

gcc -compile program.c

d)

gcc program.c -output program

14.

What is the purpose of the `main` function in a C program?

a)

To perform input operations

b)

To define the starting point of the program

c)

To handle errors

d)

To include libraries

15.

Which function is used for output in a C program?

a)

scanf

b)

printf

c)

main

d)

return

16.

What does `return 0;` signify in a C program?

a)

The program has failed

b)

The program is paused

c)

The program has executed successfully

d)

The program is restarting

17.

What library is included at the beginning of a basic C program?

a)

b)

c)

d)

18.

What is the first step in compiling and running a C program?

a)

Compile with gcc

b)

Run the executable

c)

Save code into a file

d)

Debug the code

19.

Which command is used to compile a C program in the given example?

a)

gcc C:/Users/hello.c -o C:/Users/hello.exe

b)

run C:/Users/hello.exe

c)

save C:/Users/hello.c

d)

execute C:/Users/hello.exe

20.

What is the final step to execute the compiled C program?

a)

Compile with gcc

b)

Save code into a file

c)

Run the executable

d)

Debug the code

21.

What is the first step in compiling and running a C program?

a)

Compile the code

b)

Run the executable

c)

Save the code into a file

d)

Debug the code

22.

Which command is used to compile a C program using gcc?

a)

gcc hello.c -o hello

b)

run hello

c)

execute hello

d)

compile hello.c

23.

What is the command to run the executable after compiling a C program?

a)

./run

b)

./execute

c)

./hello

d)

./start

24.

What does a relative path refer to in command line basics?

a)

Path from the root directory

b)

Path relative to the current directory

c)

Path to the home directory

d)

Path to the system directory

25.

Which command is used to change directories in the command line?

a)

ls

b)

mv

c)

cd

d)

rm

26.

What does the symbol '.' represent in command line navigation?

a)

Root directory

b)

Current directory

c)

Parent directory

d)

Home directory

27.

What does the symbol '..' represent in command line navigation?

a)

Root directory

b)

Current directory

c)

Parent directory

d)

Home directory

28.

What is an absolute path in command line terminology?

a)

Path from the current directory

b)

Path from the root directory

c)

Path to the home directory

d)

Path to the system directory

29.

What is generated after the compilation of a program?

a)

Source code

b)

Executable file

c)

Text document

d)

Script file

30.

What does the './' indicate when running a compiled program?

a)

The file is a script

b)

The file is in the root directory

c)

The executable is in the current directory

d)

The file is hidden

31.

Which data type in C is used to store integer values?

a)

float

b)

char

c)

int

d)

double

32.

What data type would you use in C to store a single character?

a)

int

b)

float

c)

char

d)

double

33.

In C, which data types are used to store decimal numbers?

a)

int and char

b)

float and double

c)

char and int

d)

double and char

34.

What is the correct way to declare a float variable named 'height' with a value of 1.75 in C?

a)

int height = 1.75;

b)

float height = 1.75;

c)

char height = 1.75;

d)

double height = 1.75;

35.

Which of the following is a correct way to assign a character literal in C++?

a)

char c = "A";

b)

char c = 'A';

c)

char c = A;

d)

char c = 65;

36.

What is the correct way to assign a float literal in C++?

a)

float pi = 3.14;

b)

float pi = '3.14';

c)

float pi = "3.14";

d)

float pi = 3;

37.

Identify the mistake in the following code: int num = 3.14;

a)

The variable type should be float.

b)

The number should be enclosed in quotes.

c)

The semicolon is missing.

d)

The variable name is incorrect.

38.

Which format specifier is used for an integer in printf?

a)

%f

b)

%d

c)

%c

d)

%s

39.

What is the output of the following printf statement: printf("Age: %d, Height: %.2f\n", 20, 1.75);?

a)

Age: 20, Height: 1.750

b)

Age: 20, Height: 1.75

c)

Age: 20, Height: 1.7

d)

Age: 20, Height: 1.7500

40.

Which format specifier is used for a string in printf?

a)

%d

b)

%f

c)

%s

d)

%c

41.

In printf, what does the format specifier %f represent?

a)

Integer

b)

Character

c)

String

d)

Float/Double

42.

Which function is used in C to take input from the user?

a)

printf

b)

scanf

c)

input

d)

get

43.

In the example provided, what data type is used for the variable 'age'?

a)

float

b)

char

c)

int

d)

double

44.

What is the purpose of the '&' symbol in the scanf function?

a)

It specifies the data type.

b)

It indicates the variable's address.

c)

It is used to print the variable.

d)

It is a placeholder for input.

45.

What is the purpose of the `scanf` function in the provided C code example?

a)

To print data to the console

b)

To read formatted input from the user

c)

To declare variables

d)

To end the program

46.

Which data type is used to store the height in the provided C code example?

a)

int

b)

char

c)

float

d)

double

47.

In the provided C code example, what does the `printf` function do?

a)

It reads input from the user

b)

It prints formatted output to the console

c)

It declares variables

d)

It ends the program

48.

What function is used to take multiple inputs from the user at once in C programming?

a)

printf

b)

scanf

c)

gets

d)

puts

49.

In the example provided, which data type is used for the variables math, english, and physic?

a)

int

b)

double

c)

float

d)

char

50.

What is the correct format specifier used in the scanf function to read float values?

a)

%d

b)

%c

c)

%s

d)

%f

51.

In the example, how are the variables passed to the scanf function?

a)

By value

b)

By reference

c)

As constants

d)

As strings

52.

Why do computers require compilers?

a)

To understand binary

b)

To execute programs faster

c)

To convert high-level code to binary

d)

To store data efficiently

53.

Which command is used to compile C programs?

a)

gcc

b)

g++

c)

javac

d)

python

54.

What is one of the topics explored in the learning material?

a)

Advanced machine learning algorithms

b)

Writing, compiling, and running C code

c)

History of programming languages

d)

Web development basics

55.

What do data types define in a variable?

a)

The kind of data a variable can store

b)

The speed of data processing

c)

The color of the data

d)

The location of data storage

56.

Which of the following is NOT determined by data types?

a)

Memory size

b)

Range of values

c)

Valid operations

d)

Network speed

57.

Which of the following is an integer type?

a)

float

b)

char

c)

double

d)

string

58.

Which category does the 'double' data type belong to?

a)

Integer types

b)

Floating-point types

c)

Character types

d)

Boolean types

59.

What is the main difference between signed and unsigned types?

a)

Signed types can only represent positive values.

b)

Unsigned types can represent both negative and positive values.

c)

Signed types can represent both negative and positive values.

d)

Unsigned types can represent negative values.

60.

Which of the following is true about unsigned types?

a)

They can represent negative values.

b)

They can only represent positive values, including zero.

c)

They have a smaller positive range than signed types.

d)

They can represent both negative and positive values.

61.

Given the code snippet below, what is the value of 'a'?

a)

10

b)

-10

c)

0

d)

20

62.

What is the size of a char type in C?

a)

2 bytes (usually 16 bits)

b)

1 byte (usually 8 bits)

c)

4 bytes (usually 32 bits)

d)

8 bytes (usually 64 bits)

63.

What is the range of a signed char type in C?

a)

0 to 255

b)

-128 to 127

c)

-256 to 255

d)

0 to 127

64.

What is the range of an unsigned char type in C?

a)

0 to 127

b)

-128 to 127

c)

0 to 255

d)

-255 to 255

65.

Which format specifier is used for a character in C?

a)

%d

b)

%f

c)

%c

d)

%s

66.

Which of the following is a valid declaration of a char variable in C++?

a)

char letter = 'A';

b)

char digit = "9";

c)

char wrong = 300;

d)

char out = "A";

67.

Why is the declaration `char wrong = "A";` considered invalid in C++?

a)

It uses double quotes, which are for strings.

b)

It exceeds the range of char.

c)

It uses single quotes, which are for strings.

d)

It is missing a semicolon.

68.

What is the reason for the invalidity of the declaration `char out = 300;` in C++?

a)

It uses double quotes.

b)

It exceeds the range of char.

c)

It uses single quotes.

d)

It is missing a semicolon.

69.

What is the size of the 'short' type on most systems?

a)

1 byte (8 bits)

b)

2 bytes (16 bits)

c)

4 bytes (32 bits)

d)

8 bytes (64 bits)

70.

What is the range of a 'signed short' type?

a)

-65,535 to 65,535

b)

-32,768 to 32,767

c)

0 to 32,767

d)

0 to 65,535

71.

What is the range of an 'unsigned short' type?

a)

-32,768 to 32,767

b)

0 to 32,767

c)

0 to 65,535

d)

-65,535 to 65,535

72.

What is the format specifier for a 'short' integer?

a)

%d

b)

%f

c)

%hd

d)

%ld

73.

What is the valid range of values for a 'short' data type in most programming languages?

a)

-32,768 to 32,767

b)

0 to 65,535

c)

-128 to 127

d)

0 to 255

74.

Why is the assignment 'short wrong = 40000;' considered invalid?

a)

It exceeds the maximum value for 'short'

b)

It is a syntax error

c)

'short' cannot store positive numbers

d)

'short' requires a decimal value

75.

What is the purpose of using 'unsigned short' in programming?

a)

To allow negative values

b)

To increase the maximum positive value

c)

To store decimal numbers

d)

To store characters

76.

What is the size of an int type on most systems?

a)

2 bytes (16 bits)

b)

4 bytes (32 bits)

c)

8 bytes (64 bits)

d)

1 byte (8 bits)

77.

What is the range of a signed int type?

a)

0 to 4,294,967,295

b)

-2,147,483,648 to 2,147,483,647

c)

-1,073,741,824 to 1,073,741,823

d)

0 to 2,147,483,647

78.

What is the range of an unsigned int type?

a)

-2,147,483,648 to 2,147,483,647

b)

0 to 2,147,483,647

c)

0 to 4,294,967,295

d)

-1,073,741,824 to 1,073,741,823

79.

Which format specifier is used for an int type in C?

a)

%f

b)

%c

c)

%d or %i

d)

%s

80.

Which of the following is a valid declaration of an integer variable in C++?

a)

int score = 100;

b)

int score = 3.14;

c)

int score = "100";

d)

int score = true;

81.

Why is the declaration `int invalid = 3.14;` considered invalid in C++?

a)

Because 3.14 is a string.

b)

Because 3.14 is a boolean.

c)

Because 3.14 is a float.

d)

Because 3.14 is a character.

82.

What is the purpose of using `unsigned int` in C++?

a)

To store negative numbers.

b)

To store floating-point numbers.

c)

To store only positive numbers.

d)

To store characters.

83.

What is the size of a 'long' type variable in bytes, depending on the system?

a)

2 or 4 bytes

b)

4 or 8 bytes

c)

8 or 16 bytes

d)

1 or 2 bytes

84.

What is the approximate range of a signed 'long' type variable for 8 bytes?

a)

-9.2e18 to 9.2e18

b)

-4.6e18 to 4.6e18

c)

-1.8e18 to 1.8e18

d)

-2.3e18 to 2.3e18

85.

What is the range of an unsigned 'long' type variable for 8 bytes?

a)

0 to 9.2e18

b)

0 to 18.4e18

c)

0 to 4.6e18

d)

0 to 1.8e18

86.

Which format specifier is used for an unsigned 'long' type in C?

a)

%ld

b)

%lu

c)

%lf

d)

%lx

87.

Which of the following is a valid declaration of a long integer in programming?

a)

long population = 7800000000;

b)

unsigned long big = 4000000000;

c)

long wrong = "hello";

d)

long number = "12345";

88.

Why is the declaration `long wrong = "hello";` considered invalid?

a)

Because "hello" is not a number

b)

Because long cannot store strings

c)

Because it lacks a semicolon

d)

Because it uses an incorrect data type

89.

What is the purpose of using `unsigned long` in a variable declaration?

a)

To store negative numbers

b)

To store larger positive numbers

c)

To store decimal numbers

d)

To store characters

90.

What is the size of the float type in bytes?

a)

2 bytes

b)

4 bytes

c)

8 bytes

d)

16 bytes

91.

What is the approximate range of values for the float type?

a)

1.2E-10 to 3.4E+10

b)

1.2E-20 to 3.4E+20

c)

1.2E-38 to 3.4E+38

d)

1.2E-50 to 3.4E+50

92.

How many decimal digits of precision does the float type approximately have?

a)

5 decimal digits

b)

7 decimal digits

c)

10 decimal digits

d)

15 decimal digits

93.

What is the format specifier used for the float type?

a)

%d

b)

%c

c)

%f

d)

%s