Doubt in switch case
Posted
by
user302593
on Stack Overflow
See other posts from Stack Overflow
or by user302593
Published on 2011-03-05T07:09:14Z
Indexed on
2011/03/05
7:24 UTC
Read the original article
Hit count: 124
c
Hi..
When i executes the following program it get the user input for account details and then print it correctly...But it cannot read the opt value(y/n)..it automatically calls again..i want to exit the program when i press n value... please help to solve this problem..
char opt;
do
{
//Getting user input
printf("\n Enter the Account Number:\n ");
scanf("%d",&gAccNo_i);
printf("\n Enter the Account Holder's Name:\n ");
scanf("%s",gCustName_c);
printf("\n Enter the Balance Amount:\n ");
scanf("%f",&gBlncAmt_f);
//Printing the inputted data.
printf("\n Account Number : %d",gAccNo_i);
printf("\n Customer Name : %s",gCustName_c);
printf("\n Balance Amount : %f",gBlncAmt_f);
printf("\n Do u want to wish to continue?(y/n)");
scanf("%c",&opt);
}while(opt!='n');
© Stack Overflow or respective owner