Can any one explain how this switch case loop works?

Mangesh

New member
include <stdio.h>
void main( )
{
int i = 1 ;
switch ( i - 2 )
{
case -1 :
printf ( "\nFeeding fish" ) ;
case 0 :
printf ( "\nWeeding grass" ) ;
case 1 :
printf ( "\nmending roof" ) ;
default :
printf ( "\nJust to survive" ) ;
}
}


When I run this program, it shows output as
Feeding fish
Weeding grass
mending roof
Just to survive
But its very hard to debug this program.
Could anyone elaborate the above example?

Regards,
Mangesh
 
Back
Top