100% switch program with & without break statement
/*In case '2' ...this is character '2' and not integer 2
#include <stdio.h>
int main()
{
int z=4;
switch(z)
{
case 1: printf("\n MahArAShTra is famous for onions");
case 4: printf("\n shadow of main temple of TanjAvur does not fall on earth");
case '2': printf("\n 15-8-1947 is friday"); /*as there is no break statement in the above case 4, even this line gets printed on output screen*/
break;
case 7: printf("this line wont get printed because in above case '2', a break is encountered and so command will go out of switch") ;
}
}
#include <stdio.h>
int main()
{
int z=4;
switch(z)
{
case 1: printf("\n MahArAShTra is famous for onions");
case 4: printf("\n shadow of main temple of TanjAvur does not fall on earth");
case '2': printf("\n 15-8-1947 is friday"); /*as there is no break statement in the above case 4, even this line gets printed on output screen*/
break;
case 7: printf("this line wont get printed because in above case '2', a break is encountered and so command will go out of switch") ;
}
}
ఔట్పుట్ తెర మీద ఇలా ..
shadow of main temple of TanjAvur does not fall on earth
15-8-1947 is friday
15-8-1947 is friday
కామెంట్లు
కామెంట్ను పోస్ట్ చేయండి
దయచేసి మీ సలహాలను సూచనలను స్పష్టంగా పేర్కొనగలరు. plz see that ur comments are 'acceptable' in a value based society.