हिंदी

Rewrite the following program segment using if-else statements instead of the ternary operator: String grade = (mark >= 90) ? “A” : (mark >= 80) ? “B” : “C”;

Advertisements

प्रश्न

Rewrite the following program segment using if-else statements instead of the ternary operator: 
String grade = (mark >= 90) ? “A” : (mark >= 80) ? “B” : “C”;

संक्षेप में उत्तर
Advertisements

उत्तर १

The code using if-else statement is:
if (mark >= 90)
{
String grade = “A”;
}
else
{
if ( mark >= 80)
{
String grade = “B”;
}
else
{
String grade = “C”;
}
}

shaalaa.com

उत्तर २

String grade; 
if (marks >= 90)
grade = "A";
else if (marks >= 80)
grade = "B"; 
else
grade = "C";
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 1.04: Operators in Java - EXERCISES [पृष्ठ ४४]

APPEARS IN

अविचल Computer Applications [English] Class 10 ICSE
अध्याय 1.04 Operators in Java
EXERCISES | Q V. 7. (a) | पृष्ठ ४४
अविचल Computer Applications [English] Class 10 ICSE
अध्याय 1.08 Conditional Statements in Java
Review Insight | Q 6. | पृष्ठ ९७
Advertisements
Share
Notifications



      Forgot password?
Use app×