# 3 Lecture

## Comparison and Conditions

Comparison and conditions are fundamental concepts in programming that involve evaluating expressions and executing code based on the result. Comparisons are made using relational operators like <, >, ==, <=, >=, and != to determine if two value

## Important Mcq's Midterm & Finalterm Prepration Past papers included

1. Which operator is used to check for equality in programming languages? a) = b) == c) === d) != Answer: b) == Which of the following is a relational operator? a) ! b) || c) && d) > Answer: d) > What is the result of the following comparison in Python: 5 > 3? a) True b) False c) Syntax Error d) None of the above Answer: a) True Which of the following is not a logical operator? a) ! b) || c) <= d) && Answer: c) <= What is the output of the following code: arduino Copy code int a = 5; if (a < 10) { printf("a is less than 10"); } a) a is less than 10 b) a is greater than 10 c) a is equal to 10 d) Compilation Error Answer: a) a is less than 10 What is the output of the following code: css Copy code int a = 10; if (a > 5 && a < 15) { printf("a is between 5 and 15"); } a) a is between 5 and 15 b) a is less than 5 c) a is greater than 15 d) Compilation Error Answer: a) a is between 5 and 15 Which of the following control structures is used to execute code based on multiple conditions? a) if-else b) switch-case c) while d) for Answer: b) switch-case Which of the following is the correct syntax for an if-else statement in C? a) if (condition) { // code block } else { // code block } b) if (condition) // code block else // code block c) if (condition) // code block else { // code block } d) if (condition) { // code block } else // code block Answer: a) if (condition) { // code block } else { // code block } What is the output of the following code: css Copy code int a = 5; int b = 3; if (a > b) { printf("a is greater than b"); } else { printf("a is less than or equal to b"); } a) a is greater than b b) a is less than or equal to b c) a is equal to b d) Compilation Error Answer: a) a is greater than b Which of the following operators is used to check for inequality? a) ! b) == c) != d) <> Answer: c) !=