Chapter 7- Notes of C Operators & Conditional & Looping Statements
Chapter 7- Notes of C Operators & Conditional & Looping Statements
Q.2 Identify whether the statement is true or false. Rewrite the correct
statement if the statement is false.
1) Use the else if statement to specify a new condition if the first condition is true.
Ans: False - Use the else if statement to specify a new condition if the first condition is false.
3) When you know exactly how many times you want to loop through a block of code, use
the while loop.
Ans: False - When you know exactly how many times you want to loop through a block of code, use
the for loop.
5) The return value of a comparison operator is either 1 or 0, which means true (1) or false (0).
Ans: True
Syntax: if (condition) {
// block of code to be executed if the condition is true
}
Example:
#include <stdio.h>
int main() {
if (20 > 18) {
printf("20 is greater than 18");
}
return 0;
}
iii) Comparison operators: These are used to compare two values or variables. It helps us to find
answers and make decisions.
Ans: For loop: When you know exactly how many times you want to loop through a block of
code, use the for loop.
Expression 1 is executed (one time) before the execution of the code block.
Expression 2 defines the condition for executing the code block.
Expression 3 is executed (every time) after the code block has been executed.