Hey guys! Everything worked out, I just have one more question. My program compiles and works fine, but how do I make it so that you can use Y and N for true and false in loops?
Code
#include <stdio.h>
int main()
{
int x;
int a, b, c, d, e;
int answer;
do
{
printf("Please enter a five digit number: ");
scanf("%d", &x);
a = x / 10000;
b = (x / 1000) % 10;
c = ((x / 100) % 100) % 10;
d = (((x / 10) % 1000) % 100) % 10;
e = x % 10;
printf("The digits of %d are: ", x);
printf("%d %d %d %d %d\n", a,b,c,d,e);
printf("Would you like to try again? 1 to continue or 0 to stop: ");
scanf("%d", &answer);
}
while(answer != 0);
printf("Goodbye!\n");
return 0;
}
So as you can see, I have "Would you like to try again? 1 to continue or 0 to stop." How can I make it "Would you like to try again? Y or N:"
I tried adding:
char answer;
...
scanf("%s", &answer)
while(answer != n);
But obviously that doesn't work. How can I make it work?
This post was edited by Saterial on Jan 31 2013 02:35pm