
I have done some operation, and want to repeat same operation again at users choice. but its not working properly. I am using goto statement.
void main()
{ float rs, p;
char z;
clrscr();
rep :
printf("\nEnter the value rs");
scanf("%f",&rs);
p=rs*100;
printf("\n\npaisa =%2.f ",p);
printf("\n do you want to access operation once again? press y/n");
if(z='y') /* i have check this also by if(z=='y') but its not working. */
goto rep;
getch();
}
problem happening is either its repeating again and again.. or its not repeating according to users choice.

try this...
void main() { float rs,p; char z='y'; clrscr(); while(z=='y') { printf("\nEnter the value rs"); scanf("%f",&rs); p=rs*100; printf("\n\npaisa =%2.f ",p); printf("\n do you want to access operation once again? press y/n"); scanf("%c",z); } getch(); }

try this...
void main() { float rs,p; char z='y'; clrscr(); while(z=='y') { printf("\nEnter the value rs"); scanf("%f",&rs); p=rs*100; printf("\n\npaisa =%2.f ",p); printf("\n do you want to access operation once again? press y/n"); scanf("%c",z); } getch(); }

void main() { float rs,p; char z; clrscr(); rep : ; printf("\nEnter the value rs"); scanf("%f",&rs); p=rs*100; printf("\n\npaisa =%2.f ",p); printf("\n do you want to access operation once again? press y/n"); if(z=='y') /* i have check this also by if(z=='y') but its not working. */ goto rep; getch();
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.