What are the if Statement ???
if Statement is a Conditional Control Structure which is used to check only if the condition is true. In this if the condition is true then it will execute a block of code otherwise it shows nothing.
Syntax: –
Here is the syntax of if Statement,
if (condition) {
// code block to execute if condition is true
}
Here, ‘condition’ is an expression that evaluates to either true or false.
C language Notes
Example: –
Let’s understand this if Statement concepts briefly by creating a example,
#include <stdio.h> int main() { int num = 10; // If statement example if (num > 0) { printf("%d is a positive number.\n", num); } return 0; }
Explanation about Example:
Here we use if statement, which is used to check “num” variables is positive or not. If the Condition is true means “num” is positive then it will execute the block of code and shows the Output.