Can anyone please tell me why the printf statement is getting executed 2 times ?
do {
printf("\n Enter the choice: a to add, d to display, q to exit: ");
scanf("%c",&choice);
switch(choice) {
case 'a':
addData();
break;
case 'd':
display();
break;
}
} while (choice != 'q');
I am expecting the following:
Enter the choice: a to add, d to display, q to exit: a
Enter the choice: a to add, d to display, q to exit: d
But I am getting the following:
Enter the choice: a to add, d to display, q to exit: a
Enter the choice: a to add, d to display, q to exit:
Enter the choice: a to add, d to display, q to exit: d
Can anyone please let me know, what is the issue behind the middle line ?
Thanks, Meghdeep