- if statement
- if else statement
- nested if else
- switch statement
if statement:
a.Use
if condition to specify a block of code to be executed if a condition is true 
it only execute block of code only wgen given condition is true otherwise it does nothing
in the output user enter negative no and program not expected 
if else statement:
a)If-else statement executes a block of code
b)If condition is true if statement execute and block of if statement
execute 
c)Otherwise control is transfer to else part
so in this code if number is not positive then it is negative.
program to check number is even or odd
the condition we applied if(number%2==0) mean that every time when we mode(%) with two it always be zero so the no that divide on 2 always zero if no is not divide by 2 else part executed mean it is odd no.
nested if else:
 
nested if-else is used to apply more then one if condition or else condition to make program more effective in above example if we enter  any negative even no in the program it print even but we only want positive no so to deal with so we write the program for it 





 
 
No comments:
Post a Comment