COMPUTER SOFTWARE
PROGRAMMING LANGUAGES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
To provide a response if a statement is not met
|
|
To provide a response if a statement is met
|
|
A loop with a condition set at the start
|
|
Used in a question as part of the decision process
|
Detailed explanation-1: -Some alternatives to the if-else statement in C++ include loops, the switch statement, and structuring your program to not require branching.
Detailed explanation-2: -If you require code to run only when the statement returns true (and do nothing else if false) then an else statement is not needed. On the other hand if you need a code to execute “A” when true and “B” when false, then you can use the if / else statement.
Detailed explanation-3: -Conditionals (or Selection): which are used to execute one or more statements if a condition is met. Loops (or Iteration): which purpose is to repeat a statement a certain number of times or while a condition is fulfilled.
Detailed explanation-4: -if (score >= 90) grade = ‘A’; The following example displays Number is positive if the value of number is greater than or equal to 0 . If the value of number is less than 0, it displays Number is negative . if (number >= 0) printf("Number is positive"); else printf("Number is negative");