why getchar() doesn't read the input?

45 views Asked by At
#include<stdio.h>
int main(void){
    
    int character;
    double balance,amount;

    printf("Enter the balance: ");
    scanf("%lf",&balance);
    printf("Enter the transaction type: ");
    character = getchar();
    
    if(character == 'w' || character =='W'){
        
        printf("\nYou have selected to withdraw money");
        printf("\nEnter the amount: ");
        scanf("%lf",&amount);
        balance -=amount;
        printf("\nnew balalnce:%lf ",balance);
        
    }else if(character == 'd' || character =='D'){
        
        printf("\nYou have selected to deposit money");
        scanf("%lf",&amount);
        balance +=amount;
        printf("\nnew balalnce:%lf ",balance);
        
    }
    
    return 0;
}
0

There are 0 answers