Site icon DataFlair

C Program For Goto Statement

Program 1

// Result Processing program,
#include<stdio.h>
#include<conio.h>
int main()
{
      int h,m,e,c,total,per;
      hindi:printf("\nEnter marks of Hindi");
      scanf("%d",&h);
      if(h>100)
     { 
      printf("\nInvalid marks of hindi enter again..........\n");
      goto hindi;
     }
     eng:printf("\nEnter marks of English");
      scanf("%d",&e);
      if(e>100)
     { 
      printf("\nInvalid marks of english enter again..........\n");
      goto eng;
     }
     math:printf("\nEnter marks of Maths");
      scanf("%d",&m);
      if(m>100)
     { 
      printf("\nInvalid marks of maths enter again..........\n");
      goto math;
     }
      comp:printf("\nEnter marks of Computer");
      scanf("%d",&c);
      if(c>100)
     { 
      printf("\nInvalid marks of computer enter again..........\n");
      goto comp;
     }
    total=h+m+e+c;
    per=total/4;
    printf("\nTotal marks is %d ",total);   
    printf("\nPercentage is %d",per);   
    if(per<35)
       printf("\nYou are fail.... ");   
    if(per>=35 && per<45)
      printf("\nYou are pass in III division.... ");   

    if(per>=45 && per<60)
       printf("\nYou are pass in II division.... ");   
    if(per>=60)
       printf("\nYou are pass in I division.... ");   
}

 

Exit mobile version