+ 1
Why we use if statement?
We use if for selection
5 Answers
+ 4
The if statement allows you to control if a program enters a section of code or not based on whether a given condition is true or false.
+ 4
Yes the condition must be true
if the condition became false then we use else
+ 4
syntax
if(a==b)
{
a==0;
}
else
{
b==0;
}
+ 2
while running our programs, we try to check certain things and make a decision like if I see watermelons in that store, I will buy two of it
+ 1
we use if statement for checking any condition
eg. if we want to check the number is great than 2 or not
then we will use if condition for that
like
if(num>2)
{
//your code
}