what is an if statement ? give two examples .
Answers
Answered by
4
Below is a general example of an if statement, not specific to any particular programming language. if (X < 10) { print "Hello John"; } In the example above, if the value of X were equal to any number less than 10, the program displays, "Hello John" when the script is run.
Make me as brainliest
Answered by
3
An if statement is a conditional statement that demonstrates whether the condition is true or false and then performs function accordingly.
- If a certain condition is true it will execute the function and if the condition is false then it will not execute the function.
- It is used as a decision-making statement to execute a specific function or not.
- Examples of if statement in C++ language are:
- if (10 > 5) { cout << "10 is greater than 5"};
- if (10 < 5) { cout << "10 is samller than 5"}; (Function will not run)
Similar questions