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.This C Program For Hotel Management System definitely has a wide scope to minimize errors in the making of bills and it also limits the delay of delivering bills to the customers which can include taxes on the basis of their expenditure.Here is the simple program for Hotel Management System using switch case in C.

The switch statement is C multi-way branch statement. It is used to take the place of long if-else chains, and make them more readable. However, unlike if statements, one may not use inequalities; each value must be concretely defined.

The goto statement is a jump statement which is sometimes also referred to as unconditional jump statement. The goto statement can be used to jump from anywhere to anywhere within a function. Goto statement in C is a jump statement that is used to jump from one part of the code to any other part of the code in C.

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

Output

        MENU CARD
                1.COFFEE        Rs:15
                2.TEA           Rs:10
                3.COLD COFFEE   Rs:25
                4.MILK SHAKE    Rs:50

 Enter Your choice  : 1

You have selected Coffee
Enter The Qty : 3

Do You want to continue press 1: 1

        MENU CARD
                1.COFFEE        Rs:15
                2.TEA           Rs:10
                3.COLD COFFEE   Rs:25
                4.MILK SHAKE    Rs:50

 Enter Your choice  : 4

You have selected Milk Shake
Enter The Qty : 2

Do You want to continue press 1: 2

Total amount : 145
Thank You Come Again

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