Mail Archives: djgpp/1999/12/07/17:39:28
>
> main ()
> {
> int ans,h,a,b;
> printf("Enter -1 to end\n");
> do{
> srand(time(NULL));
> a=1+(rand()%9);
> b=1+(rand()%9);
> printf("How much is %d times %d? ",a,b);
> ans=a*b;
> scanf("%d",&h);
> if (ans == h)
> printf("Very Good!\n");
> else
> if (ans!=h&&h!=-1)//to be able to qiut I add h!=-1
> {
> do{{
> printf("No. Please try again.\n");
> printf("? ");
> scanf("%d",&h);}
> if (ans == h)
> printf("Very Good!\n");} while (ans != h, ans != -1);//<-----
And there is another error. ans is always !=-1. It should be h!=-1
>
> }} while (ans != -1);<----
And the same again
>
> if (ans == -1)<-----
and again.
>
> printf("That's all for now. Bye.");
> return 0;
> }
This ought to do it.
/Peter
- Raw text -