edited by
661 views
1 votes
1 votes

Output of the following program?

#include <stdio.h>

char input[ ] = "SSSWILTECH1\1\11W\1WALLMP1";

main() {

int  i,c;

for( i=2 ; ( c=input[i] ) ! = '\0' ; i++) {

switch(c) {

case 'a' : putchar( 'i' );continue;

case '1' : break;

case 1 : while( ( c=input[++i] )!= '\1' && c!= '\0' );

case 9 : putchar( 'S' );

case 'E' :

case 'L' : continue;

default : putchar (c);

continue;

}

putchar( ' ' );

}

putchar( '\n' );

}

edited by

1 Answer

Best answer
1 votes
1 votes
        #include <stdio.h>
        char input[ ] = "SSSWILTECH1\1\11W\1WALLMP1";
        int main(void) {
        	int i,c;
            for(i=2;(c=input[i])!='\0';i++){//Printing starts at a[2]
            switch(c) {
            case 'a' : putchar( 'i' );continue;
            case '1' : break;
            case 1 : while( ( c=input[++i] )!= '\1' && c!= '\0' );
            case 9 : putchar( 'S' );
            case 'E' :
            case 'L' : continue;
           default : putchar (c);
           continue;
            }
			putchar( ' ' );
			}
			putchar( '\n' );
        	return 0;
        }

Printing starts at a[2]=S, and case S is by default print S. 'L' and 'E' executes continue statements.

selected by

Related questions

1 votes
1 votes
2 answers
1
Hira Thakur asked Sep 14, 2018
1,419 views
int main() { int a =50; switch(a) { default: a=45; case 49: a++; case 50: a ; case 51: a =a+1; } printf("%d",a); }my doubt is the default case is not executed here why??,...
0 votes
0 votes
1 answer
2
joshi_nitish asked Jun 28, 2017
551 views
BREAK can be used in switch-case but CONTINUE is not allowed in switch-case but CONTINUE is allowed in DEFAULT case of switch-case..is it correct??
3 votes
3 votes
2 answers
3
Sankaranarayanan P.N asked Oct 27, 2016
393 views
What will be the output of the following C program fragment?int n =1; switch(n) { case 1: printf("One"); case 2: printf("Two"); case 3: case 4: case 5: default: printf("W...