From: Peter Danielsson Newsgroups: comp.os.msdos.djgpp Subject: Re: Answer right and then wrong... Date: Tue, 07 Dec 1999 14:35:04 +0100 Organization: Student Lines: 47 Message-ID: <384D0D07.92629B46@efd.lth.se> References: <82i1eb$e5c$1 AT imsp026 DOT netvigator DOT com> NNTP-Posting-Host: dialin-45-6.student.lu.se Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.6 [en] (Win98; I) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com > > 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