# Thread: Can't get my program to repeat until 0 is entered

1. ## Can't get my program to repeat until 0 is entered

Basically what I was asked to do is enter a number and then create a program to reverse said number and the program continues to do that until the user enters the digit 0. While my program does reverse any entered number the user enters, it, however, doesn't ask me again for another number to reverse. The program just ends.

This is what I have so far:

Code:
```#include <stdio.h>

main(){

int n, reverse=0;

printf("Enter a number to reverse (enter 0 to end): \n");
scanf("%d", &n);

while (n !=0)
{

reverse=reverse*10;
reverse=reverse+n%10;
n=n/10;

}

printf("The reversed digit is: %d\n", reverse);

return 0;
}```
What can I do to

2. Add another loop the contains the first loop and the scanf.

Tim S.

3. What would I need to put for the conditions to do so? (sorry I'm still pretty new to all of this)

4. Code:
```int main(array<System::String ^> ^args)
{
int n, reverse=0;

printf("Enter a number to reverse (enter 0 to end): \n");
scanf("%d", &n);

while(n!=0) {

while(n != 0) {
if( n == 0)
break;

reverse=reverse*10;
reverse=reverse+n%10;
n=n/10;
}

printf("The reversed digit is: %d\n", reverse);

n = 0;
reverse = 0;

printf("Enter a number to reverse (enter 0 to end): \n");
scanf("%d", &n);

}

return 0;
}```
Add a while loop within a while loop, and if n == 0, break out of the loop. And set n and reverse to 0 after the second loop.

5. Thank you very much for your help! I understand how to it properly now.