Find the grade of the student based on the marks obtained in five subjects. Let the grade be calculated based on the following pattern: Average Mark Range Grade 91-100 A1 81-90 A2 71-80 B1 61-70 B2 51-60 C1 41-50 C2 33-40 D 21-32 E1 0-20 E2 To calculate a student’s grade based on total marks […]
November 17, 2022 | C++ | No comments
A number is even if it is divisible by two, and odd if it is not divisible by two. Some of the even numbers are − Some of the odd numbers are − program code: Output: In the code, we use the if-else block to determine whether the entered number is even or odd. Note: also […]
November 5, 2022 | C++ | No comments
In real life, we face situations where we must make decisions and decide what to do next. Similarly, the programmer must specify one or more conditions to be evaluated or tested by the program, as well as a statement or statements to be executed if the condition is determined to be true, and optionally, additional […]
September 27, 2022 | C++ | No comments
if-else ladder: The if-else-if ladder statement is used to test multiple conditions in Java. It’s used to test a single condition from a set of statements. When there are multiple conditions to execute, the if-else-if ladder makes the code easy to understand and work with. Syntax: If Else If Block data flow diagram: Example: Output: […]
April 30, 2022 | Java | No comments
The selection statement allows choosing the set of instructions for execution depending upon an expression’s truth value. Java provides two types of selection statements – if and switch. In addition, the’:?’ (ternary operator) is also used. The selection statements are also called conditional statements or decision statements. The if statement is used to test particular […]
April 30, 2022 | Java | No comments