Mail Archives: djgpp/1999/12/06/23:42:13
| From:  | "Jason Yip" <manman AT netteens DOT net>
 | 
| Newsgroups:  | comp.os.msdos.djgpp
 | 
| Subject:  | Answer right and then wrong...
 | 
| Date:  | Tue, 7 Dec 1999 12:09:13 +0800
 | 
| Organization:  | netteens.net (Hongkong Telecom IMS)
 | 
| Lines:  | 36
 | 
| Message-ID:  | <82i1eb$e5c$1@imsp026.netvigator.com>
 | 
| NNTP-Posting-Host:  | olkc10a093.netvigator.com
 | 
| X-Priority:  | 3
 | 
| X-MSMail-Priority:  | Normal
 | 
| X-Newsreader:  | Microsoft Outlook Express 5.00.2615.200
 | 
| X-MimeOLE:  | Produced By Microsoft MimeOLE V5.00.2314.1300
 | 
| To:  | djgpp AT delorie DOT com
 | 
| DJ-Gateway:  | from newsgroup comp.os.msdos.djgpp
 | 
| Reply-To:  | djgpp AT delorie DOT com
 | 
I input a wrong ans in my prog... it shows "no try again", and then I input
a correct ans, it shows "very good" AND "no try again".. that means I can't
get a correct ans when the 1st time I did wrong...
What's more, I can't quite the prog when I enter "-1".. it shows the answer
is wrong when I enter "-1"..
Can anyone helps? Thank you!!
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){
 do{{
        printf("No. Please try again.\n");
        printf("? ");
 scanf("%d",&h);}
 if (ans == h)
 printf("Very Good!\n");} while (ans != h, ans != -1);
        }} while (ans != -1);
 if (ans == -1)
 printf("That's all for now. Bye.");
return 0;
}
- Raw text -