lundi 5 mars 2018

C - If statement within case not executing

Hey guys could I please have some help. I have a C program to change through interfaces that is supposed to use a switch statement. I have gotten to the first case, but it is not executing all the lines I need it to there, particularly the if statement I need. It stops running after the first print under case Here is the code:

#include <stdio.h>

   void main()
{
int option=0,select=01;

printf("Welcome... \n   \n");
printf("1. Airtime\n2. Balance Enquiry\n3. Transfer\n");


printf("\nPlease select : ");
scanf("%d",&option);

switch(option)
{
    case 1:
        printf("\n1. Buy for self\n2. Buy for other\n");
        scanf("d", &select);
        if (select==1){
            printf("enter amt");
        }
        else if (select==2){
            printf("Enter number to send to: ");
        }
        else{
            printf("Invalid input!");
        }
}       
}   

Aucun commentaire:

Enregistrer un commentaire