View Single Post
Old Nov 21st, 2004, 6:49 AM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Fine... here's the same thing in C:

int number = 32;
int n1, n2;
int count = 1;

printf("*** Try %i ***\n", count);
printf("Enter two numbers, separated by a space, that multiply to give %i:\n", number);
scanf("%i %i", n1, n2);
while ((n1 * n2) != number) {
   printf("Wrong answer!\n\n")
   count++;
   printf("*** Try %i ***\n", count);
   printf("Enter two numbers, separated by a space, that multiply to give %i:\n", number);
   scanf("%i %i", n1, n2);
}
printf("Right answer! You got it!\n");

Granted, it's nowhere near perfect, but it's a start. As you might have noticed, I'm not exactly a pro. Of course, your solution minus the error checking wins. And about the redundant code: it's either that or use flags, if you want to signal a wrong answer. And I don't like flags
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote