Skip to main content

Introduction to Programming MCQs with Answers

Practice important Introduction to Programming MCQs with answers and explanations.

Chapter: 3
Q41:
Which data type would you use to store a small whole number?
A. long
B. float
C. short
D. double
Correct Answer: C
Chapter: 3
Q42:
Which of the following data types is used to store characters in C?
A. int
B. char
C. float
D. double
Correct Answer: B
Chapter: 3
Q43:
The arithmetic operator '%' in C is used to ___________.
A. add two numbers
B. subtract one number from another
C. divide two numbers
D. find the remainder after division
Correct Answer: D
Chapter: 3
Q44:
Which operator has the highest precedence in C?
A. +
B. -
C. *
D. /
Correct Answer: C
Chapter: 3
Q45:
In C, the statement 'x = x + 1;' means ________.
A. Add 1 to the value of x and store the result in x
B. Add 1 to the value of x and store the result in a new variable
C. Add x and 1 and store the result in 1
D. None of the above
Correct Answer: A
Chapter: 3
Q46:
In C, the expression '5 / 2' gives the result ________.
A. 2.5
B. 2
C. 5
D. None of the above
Correct Answer: B
Chapter: 3
Q47:
Which of the following statements is correct about short data type?
A. It occupies 4 bytes in memory
B. It is used to store large numbers
C. It occupies 2 bytes in memory
D. It is used to store characters
Correct Answer: C
Chapter: 3
Q48:
To store a large real number, which data type is used?
A. int
B. char
C. double
D. short
Correct Answer: C
Chapter: 3
Q49:
The statement 'cout << x;' in C will ___________.
A. display the value of x
B. display the character 'x'
C. display 'cout << x;' on the screen
D. give an error
Correct Answer: A
Chapter: 3
Q50:
The statement 'int x, y, z;' is an example of ________ in C.
A. declaration
B. assignment
C. input
D. output
Correct Answer: A
Chapter: 4
Q51:
What data type should be used to store the age of a student in the program?
A. int
B. float
C. double
D. char
Correct Answer: A
Chapter: 4
Q52:
How many variables are used to store the age of ten students in the provided program?
A. 5
B. 10
C. 15
D. 20
Correct Answer: B
Chapter: 4
Q53:
What is the purpose of the cin statement in the C++ program?
A. To display output on the screen
B. To perform arithmetic operations
C. To get input from the user
D. To exit the program
Correct Answer: C
Chapter: 4
Q54:
Which of the following is the correct statement to calculate the average age of 10 students?
A. AverageAge = TotalAge / 10;
B. AverageAge = TotalAge * 10;
C. AverageAge = TotalAge + 10;
D. AverageAge = TotalAge - 10;
Correct Answer: A
Chapter: 4
Q55:
What will be the output of the program if the average age is 12.3 but the variables are of type int?
A. 12.3
B. 12
C. 13
D. Error
Correct Answer: B
Chapter: 4
Q56:
Which operator is used to get the last digit of a number in the program that separates digits of a 4-digit number?
A. /
B. %
C. *
D. +
Correct Answer: B
Chapter: 4
Q57:
In the expression x = a * (x + b * (y + c * z * z)), which operation is performed first?
A. a * x
B. b * (y + c * z * z)
C. (y + c * z * z)
D. c * z * z
Correct Answer: D
Chapter: 4
Q58:
Which function is used to display text and variables on the screen in C++?
A. cin
B. printf
C. cout
D. scanf
Correct Answer: C
Chapter: 4
Q59:
What is the value of TotalAge if the ages of the students are 12, 13, 14, 15, 16, 17, 18, 19, 20, and 21?
A. 155
B. 160
C. 165
D. 170
Correct Answer: C
Chapter: 4
Q60:
How do you calculate the diameter of a circle in the given program?
A. diameter = radius * 3.14;
B. diameter = radius + radius;
C. diameter = radius * 2;
D. diameter = 2 * 3.14 * radius;
Correct Answer: C

Test Your Knowledge

Take a timed quiz on Introduction to Programming

🚀 Start Quiz Now