mardi 26 avril 2016

If - else Program [duplicate]

This question already has an answer here:

Hi I have this code here trying ask the user about the location.When the user enters the location it just says bye.What is wrong in my code?

#include<stdio.h>

int main ()
{

        char location[15];
        printf("1:Greencourt\n");
        printf("2:Corianthans\n");
        printf("3:Shop\n");
        printf("Enter a location\n");
        scanf("%s",location);
        if(location=="Greencourt")
        printf("Bisleri bottle cost 25 rupees\n");
        else
        if(location=="Shop")
        printf("Bisleri bottle cost 15 rupees\n");
        else
        if(location=="Corianthans")
        printf("Bisleri bottle cost 50\n");
        else
        printf("Bye");

        return 0;
}

Here is the output

1:Greencourt
2:Corianthans
3:Shop
Enter a location

Shop

Bye

Aucun commentaire:

Enregistrer un commentaire