Ask Question

What is an IF statement used for? Select all that apply.

1. Repeat sections of code Make

2. True / False decisions To count

3. user input

4. Select between options in a program

+3
Answers (1)
  1. 4 December, 23:47
    0
    The IF statement is used for: True/False decisions to count & to Select between options in a program.

    IF statement is known for decision making statement. Meaning to say, programmers used it to have an output based on decision (TRUE and FALSE). Only one final output or decision will be presented depending on the condition made. For example: The person would like to know if he can vote. According to some national rules, a person can vote if he is 18 years old and above. To do that using IF statement (in Java):

    if (age>=18)

    {

    System. out. println ("You can vote");

    }

    The condition is age >=18 meaning, if age is higher or equivalent to 18, it will produce a statement "You can vote". The TRUE value is when the condition is met or satisfied.

    IF statement supports multiple TRUE values as well. You can add two scenario on the example above: When the user input his age, the program will say that he can vote and he cannot vote:

    if age (age>=18)

    {

    System. out. println ("You can vote"):

    {

    if (age<18)

    {

    System. out. println ("You cannot vote");

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What is an IF statement used for? Select all that apply. 1. Repeat sections of code Make 2. True / False decisions To count 3. user input ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers