What will the following program print when given this input? - C Statement

C examples for Statement:if

Introduction

suppose the input is as follows.

q 
c 
h 
b 

Demo Code

#include <stdio.h> 
int main(void) 
{ 
  char ch; //from   w  w w.j  a  v a2 s .co m
 
  while ((ch = getchar()) != '#') 
  { 
       if (ch == '\n') 
            continue; 
       printf("Step 1\n"); 
       if (ch == 'c') 
            continue; 
       else if (ch == 'b') 
            break; 
       else if (ch == 'h') 
            goto laststep; 
       printf("Step 2\n"); 
       laststep:  printf("Step 3\n"); 
  } 
  printf("Done\n"); 
  return 0; 
}

Result


Related Tutorials