Skip to main content

Introduction to Programming MCQs with Answers

Practice important Introduction to Programming MCQs with answers and explanations.

Chapter: 5
Q81:
Which logical operator has a higher precedence in C?
A. ||
B. &&
C. ! (NOT)
D. != (NOT equal)
Correct Answer: B
Chapter: 5
Q82:
What is the output if 'AmerAge' is 16 and 'AmaraAge' is 14, given the code 'if (AmerAge > AmaraAge) cout << "Amer is older than Amara";'?
A. Amer is younger than Amara
B. Amer is older than Amara
C. No output will be displayed
D. Syntax error
Correct Answer: B
Chapter: 5
Q83:
If the amount is greater than 5000, which discount percentage is applied in the sample program?
A. 10%
B. 15%
C. 5%
D. 0%
Correct Answer: B
Chapter: 5
Q84:
Why should you use '15.0' instead of '15' when calculating the discount in C?
A. To ensure correct integer division
B. To avoid truncation in the division result
C. To make the code more readable
D. To avoid division by zero
Correct Answer: B
Chapter: 5
Q85:
What will happen if you don’t use braces { } after an 'if' statement in C?
A. The code may give an error
B. Only the first statement after 'if' will execute
C. All the statements after 'if' will execute
D. None of the statements will execute
Correct Answer: B
Chapter: 5
Q86:
Which statement correctly initializes a variable in C?
A. int x;
B. float x;
C. int x = 0;
D. char x = 'A';
Correct Answer: C
Chapter: 5
Q87:
What is the purpose of the 'else' block in an if/else structure?
A. To define an alternative action if the 'if' condition is false
B. To execute only when the 'if' condition is true
C. To execute only when both conditions are true
D. To check multiple conditions
Correct Answer: A
Chapter: 5
Q88:
What does 'cin >>' do in C?
A. It takes input from the user
B. It displays output on the screen
C. It compares two values
D. It assigns a value to a variable
Correct Answer: A
Chapter: 5
Q89:
What is the correct way to check if a value is not equal to 5 in C?
A. if (x == 5)
B. if (x != 5)
C. if (x = 5)
D. if (x => 5)
Correct Answer: B
Chapter: 6
Q90:
Which of the following is an example of repetition in real life?
A. Days and nights repeating monthly
B. Seasons replacing each other yearly
C. Payroll system procedures
D. All of the above
Correct Answer: D
Chapter: 6
Q91:
What is a disadvantage of calculating the sum of numbers from 1 to 1000 by writing them all in a single statement?
A. It becomes very long and tedious
B. It becomes error-prone
C. It is difficult to debug
D. It is more efficient
Correct Answer: A
Chapter: 6
Q92:
What is the correct way to find the next integer in a sequence?
A. Multiply the previous integer by 2
B. Subtract 1 from the previous integer
C. Add 1 to the previous integer
D. Divide the previous integer by 2
Correct Answer: C
Chapter: 6
Q93:
Which of the following is a correct use of the 'while' loop in C?
A. while (number <= 1000) { sum = sum + number; }
B. while (number >= 1000) { sum = sum + number; }
C. while (number = 1000) { sum = sum + number; }
D. while (number < 1000) { sum = sum + number; }
Correct Answer: A
Chapter: 6
Q94:
In a 'while' loop, when does the loop terminate?
A. When the logical expression evaluates to true
B. When the logical expression evaluates to false
C. When the loop body has been executed once
D. When the program encounters a 'break' statement
Correct Answer: B
Chapter: 6
Q95:
What will happen if the condition in a 'while' loop is never false?
A. The loop will execute indefinitely (infinite loop)
B. The loop will execute only once
C. The loop will execute a fixed number of times
D. The loop will never execute
Correct Answer: A
Chapter: 6
Q96:
What is the term used when more bits than the data type can store are wasted?
A. Overflow condition
B. Run-time error
C. Logical overflow
D. Underflow condition
Correct Answer: A
Chapter: 6
Q97:
What happens when an integer overflow occurs?
A. The program will generate a run-time error
B. The program will store an incorrect value
C. The program will terminate normally
D. The program will ask for user input again
Correct Answer: B
Chapter: 6
Q98:
What is the purpose of the 'upperLimit' variable in the sample program provided?
A. To allow the program to sum different ranges without modifying the code
B. To limit the range of numbers being summed
C. To make the program more complex
D. To simplify user input
Correct Answer: A
Chapter: 6
Q99:
How can you calculate the sum of even numbers in a given range in C?
A. By summing all integers and then dividing by 2
B. By summing only those integers that return 0 when divided by 2
C. By summing integers and checking for evenness manually
D. By summing integers divisible by 3
Correct Answer: B
Chapter: 6
Q100:
Which operator is used to determine if a number is even in C?
A. % (modulus)
B. != (not equal)
C. && (and)
D. = (equal to)
Correct Answer: A

Test Your Knowledge

Take a timed quiz on Introduction to Programming

🚀 Start Quiz Now