Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Thursday, 2 June 2016

PROBLEM 8:
Joan is planning her vacation. She is considering two different destinations. She would like to go to the one that will be less expensive for the total trip including gas, hotel room for six nights, and meals for seven days. Write a C Program to tell her which of the destinations would be the less expensive.

CODE:
 #include<stdio.h>
main()
{
    int destination1=0,destination2=0,gas,hotel,food;
    int gas2,hotel2,food2;

    printf("enter expense of gas in rupees of 1st Destination:");
    scanf("%d",&gas);
    printf("enter expense of 6 days hotel in rupees of 1st Destination:");
    scanf("%d",&hotel);
    printf("enter 7 days expense of food in rupees of 1st Destination:");
    scanf("%d",&food);
    destination1=gas+hotel+food;
    printf("Total expense of destination 1 is ----%d----\n ",destination1);


    printf("enter expense of gas in rupees of 2nd Destination\n");
    scanf("%d",&gas2);
    printf("enter expense of 6 days hotel in rupees of 2nd Destination\n");
    scanf("%d",&hotel2);
    printf("enter 7 days expense of food in rupees of 2nd Destination\n");
    scanf("%d",&food2);
    destination2=gas2+hotel2+food2;
    printf("Total expense of destination 2 is ------%d----- \n ",destination2);

    if(destination1<destination2)
    {
        printf("destination n0.1 is less expensive \n ");
    }
    else if(destination1==destination2)
    {
        printf("both have same expense");
    }

    else
        printf("destination no.2 is less expensive \n ");
    return 0;

}

Program Output:










For more problems click here

No comments:

Post a Comment