हिंदी

Give Two Differences Between the Switch Statement and the If-else Statement. - Computer Applications

Advertisements
Advertisements

प्रश्न

Give two differences between the switch statement and the If-else statement.

अंतर स्पष्ट करें

उत्तर

S. No. Switch statement if-else statement
1. In this statement, multicodes can be provided in which control transfers to different parts of the code based on the value of an expression.  In this statement, only two codes are based on either a true or a false condition. 
2. Syntax:
if (condition)
{
statements;
}
else
{
statements;
} 
Syntax:
switch (expression)
{
case constant1:
statement 1;
break;
case constant2:
statement 2;
break;
default:
statement sequence;
}
shaalaa.com
Introduction of Object-oriented Programming
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 1.08: Conditional Statements in Java - EXERCISES [पृष्ठ १००]

APPEARS IN

अविचल Computer Applications [English] Class 10 ICSE
अध्याय 1.08 Conditional Statements in Java
EXERCISES | Q V. 8. | पृष्ठ १००
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×