Hi,
I am trying to write a function that promote users to enter an arithmetic operater, if they enter a wrong character i have to promote them again to enter it.
It work fine if they enter right arithmetic operator, but if they enter wrong character, the do while loop i have loop twise for no reason, i cant find the reason. Please help me out. ( more over number of loops increase if i put more than 1 charactor, if i put one wrong charactor its only loop twice but if i put 10 it look like 11 times.)
Code:#include <stdio.h> int main(void) { char ope; do { printf("Enter an arithmetic operator (+, -, *, /): "); scanf("%c",&ope); if (ope=='+') printf("You have entered: %c\n",ope); else ; } while (ope!='+'); }