undeclared identifier in C

前端 未结 5 1463
忘掉有多难
忘掉有多难 2021-01-26 04:29

I am trying to compile a small bank program in C in visual studio 2012 express. It shows me this error \"undeclared identifier\" for almost all variables and this one too \"synt

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-26 04:53

    try this code:

    #include
    #include
    int main()
    {
        printf("Welcome to skybank\n");
        int deposit,withdraw,kbalance;
        char option;
        printf("Press 1 to deposit cash\n");
        printf("Press 2 to Withdraw Cash\n");
        printf("Press 3 to Know Your Balance\n");
        scanf("%c",&option);
        int decash,wicash;
        switch(option)
        {
        int balance;
        printf("Enter your current Balance\n");
        scanf("%d",&balance);
        case 1:
            printf("Enter the amount you want to deposit\n");
            scanf("%d",&decash);
            printf("Thank You\n");
            printf("%d have been deposited in your account\n",decash);
            break;
        case 2:
            printf("Enter the amount you want to withdraw\n");
            scanf("%d",&wicash);
            int wibal;
            wibal=balance-wicash;
            printf("Thank You\n");
            printf("%d have been withdrawed from your account\n",wicash);
            printf("Your balance is %d\n",wibal);
            break;
        case 3:
            printf("Your balance is Rs.%d\n",balance);
            break;
        default:
            printf("Invalid Input\n");
            break;
        }
        getchar();
    }
    

提交回复
热议问题