My program below isn't taking input using getchar()
. Instead, it ends after printing, "want to continue??(press y for yes and press n to reenter)"
. It doesn't take input after typing n
or N
.
void main(){
int i,arr[]={55,10,23,11,35,8,9,20},n;
char a;
printf("Given array is:\n");
for(i=0;i<8;i++)
printf("%d ",arr[i]);
do{
printf("\nEnter position where you want to insert element:");
scanf("%d",&n);
printf("You entered position %d \n",n);
printf("want to continue ??(press y for yes and press n to reenter)");
a=getchar();
} while(a=='n' || a=='N');
}