In the if else conditional statement, one set of statement(s) is executed if the condition is true, otherwise, the other set of statement(s) is executed.
| C++ | Python | ||
|---|---|---|---|
| Syntax if (condition) { statement1; statement2; ... } else { statement1; statement2; ... } |
Syntax if condition: statement1; statement2; ... else: statement1; statement2; ... |
||
Example int a = 10; int b = 15; if (a<b) { cout<<"a < b."; } else { cout<<"a >= b."; } | Example a,b = 10, 15; if a<b: print("a < b") else: print("a >= b") |
No comments:
Post a Comment