help on a do-while loop please...

can you guys help me to see if there is something wrong with my do-while loop..?><
i was trying to do a continues loop but when i try to enter a y, it got error or something and it wont continue...
help..TTATT

#include<stdio.h>
void main()
{
char y, respond;
int a;

do{
a=0000;
a++;
printf("Receipt No.000%d\n", a);
printf("Anymore?(Yes/No)", respond);
scanf("%c",respond);
return ;
}while (respond = 'y');
printf("END OF RECEIPT");

}
Last edited on
Maybe you should Initialize respond with 'y'.
I'm not exactly sure this is what you're trying to do but if you want to check if respond equals 'Y', your third to last line needs to be

} while (respond == 'y');

The double equal sign checks for likeness while the single one sets one equal to the other.
Good luck!
Do you want the variable "a" to be set to 0 each time the loop is executed? the first two lines of the loop will set "a" equal to zero and then increment it by one so you will have "a" equal to 1 practically the entire time. I don't think that's what you want. You probably want the line

a=0000;

just before the do-while loop.
Topic archived. No new replies allowed.