Hotel Management using goto in C


In this Example, you will learn to create the goto statement in C programming. Also, you will learn when to use a goto statement and when not to use it.

Source Code

#include<stdio.h>
 
int main()
{
    int ch,qty,i,net=0;
    joes:
    printf("\n\tMENU CARD");
    printf("\n\t\t1.COFFEE        Rs:15");
    printf("\n\t\t2.TEA           Rs:10");
    printf("\n\t\t3.COLD COFFEE   Rs:25");
    printf("\n\t\t4.MILK SHAKE    Rs:50");
    printf("\n\n Enter Your choice  : ");
    scanf("%d",&ch);
    switch(ch)
    {
    case 1:
        printf("\nYou have selected Coffee");
        printf("\nEnter The Qty : ");
        scanf("%d",&qty);
        net=net+(qty*15);
        break;
     case 2:
        printf("\nYou have selected Tea");
        printf("\nEnter The Qty : ");
        scanf("%d",&qty);
        net=net+(qty*10);
        break;
     case 3:
        printf("\nYou have selected Cold Coffee");
        printf("\nEnter The Qty : ");
        scanf("%d",&qty);
        net=net+(qty*25);
        break;
     case 4:
        printf("\nYou have selected Milk Shake");
        printf("\nEnter The Qty : ");
        scanf("%d",&qty);
        net=net+(qty*50);
        break;
     default:
          printf("\nInvalid Product Selection");
          break;
 
    }
 
    printf("\nDo You want to continue press 1: ");
    scanf("%d",&i);
    if(i==1)
    {
        goto joes;
    }
     printf("\nTotal amount : %d",net);
     printf("\nThank You Come Again");
    return 0;
}
 
To download raw file Click Here

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C


Learn All in Tamil © Designed & Developed By Tutor Joes