please answer me.show why my code does not loop and it repeats question number 1.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

/*prints the ASCII art for "FAIL"*/
void ascii_fail(void)
{
	printf("     /%c__%c         /%c  %c\n", 92,92,92,92);
	printf("    /:/ _/_       /::%c  %c       ___ \n", 92,92);
	printf("   /:/ /%c__%c     /:/%c:%c  %c     /%c__%c\n", 92,92,92,92,92,92,92);
	printf("  /:/ /:/  /    /:/ /::%c  %c   /:/__/      ___     ___\n", 92,92);
	printf(" /:/_/:/  /    /:/_/:/%c:%c__%c /::%c  %c     /%c  %c   /%c__%c\n", 92,92,92,92,92,92,92,92,92);
	printf(" %c:%c/:/  /     %c:%c/:/  %c/__/ %c/%c:%c  %c__  %c:%c  %c /:/  /\n", 92,92,92,92,92,92,92,92,92,92,92,92);
	printf("  %c::/__/       %c::/__/       ~~%c:%c/%c__%c  %c:%c  /:/  /\n", 92,92,92,92,92,92,92,92);
	printf("   %c:%c  %c        %c:%c  %c          %c::/  /   %c:%c/:/  /\n", 92,92,92,92,92,92,92,92,92);
	printf("    %c:%c__%c        %c:%c__%c         /:/  /     %c::/  /\n", 92,92,92,92,92,92,92);
	printf("     %c/__/         %c/__/         %c/__/       %c/__/\n", 92,92,92,92);
}

/*prints the ASCII art for "Good!"*/
void ascii_good(void)
{	printf(" .88888.                          dP dP\n");
	printf("d8'   `88                         88 88\n");
	printf("88        .d8888b. .d8888b. .d888b88 88\n");
	printf("88   YP88 88'  `88 88'  `88 88'  `88 dP\n");
	printf("Y8.   .88 88.  .88 88.  .88 88.  .88\n");
	printf(" `88888'  `88888P' `88888P' `88888P8 oo\n");
	printf("oooooooooooooooooooooooooooooooooooooooo\n");

}

/*prints the ASCII art for "PERFECT!"*/
void ascii_perfect(void)
{	printf("  ____   U _____ u   ____     _____U _____ u   ____  _____   _\n");
	printf("U%c  _%c\\ u\\%c ___%c%c/U %c  _%c\\ u %c%c ___%c%c ___%c%c/U /%c___%c%c_ %c _%cU%c%c%cu\n", 124,34,124,34,124,124,34,124,34,124,124,34,124,34,124,124,34,124,124,34,124);  
	printf("\\%c %c_) %c/ %c  _%c%c   \\%c %c_) %c/U%c %c_  u%c  _%c%c  \\%c %c u    %c %c  \\%c %c/\n", 124,124,124,124,124,34,124,124,124,124,124,124,124,34,124,124,124,124,124,124);
	printf(" %c  __/   %c %c___    %c  _ <  \\%c  _%c/ %c %c___   %c %c/__  /%c %c\\  %c_%c\n", 124,124,124,124,124,124,124,124,124,124,124,124,124,124);
	printf(" %c_%c      %c_____%c   %c_%c \\_\\  %c_%c    %c_____%c   \\____%cu %c_%cU  (_)\n", 124,124,124,124,124,124,124,124,124,124,124,124,124);
	printf(" %c%c>>_    <<   >>   %c%c   \\_) (  \\,- <<   >>  _%c%c  \\ _%c%c \\_  %c%c%c_\n", 124,124,47,47,47,47,47,47,124,124,124);  
	printf("(__)__)  (__) (__) (__)  (__)__)(_/(__) (__)(__)(__)__) (__)__)_)\n");
}

	
int main (void)
{
	int op,d,e;
	float score=0,items,ans,c,a,b,ratio;
	int num,count=0;
	time_t start, end;

	puts("\t\tMath Drills");
	puts("\tPutting your math skills to the test");
	puts("");

	/*requests for the number of drills to be printed*/
	printf("Enter the number of drills: ");
	scanf("&d", &items);
	puts("");

	start = time(0);

	for(count=0; count!=items; count++)
	{
		/*generates random values for a and b*/
		srand(time(NULL));
		a=rand()%100+1;
	
		srand(time(NULL)+1);
		b=rand()%100+1;
		
		/*generates random values for d and e (to be used in % operation)*/
		srand(time(NULL)+2);
		d=rand()%100+1;
	
		srand(time(NULL)+3);
		e=rand()%100+1;
	
		/*generates a random number from 0 to 4, inclusive (this will deterimine the operation to be evaluated)*/
		srand(time(NULL)+4);
		op=rand()%5;
		
		num=count+1;
		
		/*prints the question provided by the random numbers*/
		switch(op)	
		{
			case 0:	c=a+b;
						printf("Question %d].\t%.0f + %.0f = ", num,a,b);
						scanf("%f", &ans);
						break;
		
			case 1:	c=a-b;
						printf("Question %d].\t%.0f - %.0f = ", num,a,b);
						scanf("%f", &ans);
						break;
		
			case 2:	c=a*b;
						printf("Question %d].\t%.0f * %.0f = ", num,a,b);
						scanf("%f", &ans);
						break;
		
			case 3:	c=a/b;
						printf("Question %d].\t%.0f / %.0f = ", num,a,b);
						scanf("%f", &ans);
						break;
					
			default:	c=d%e;
						printf("Question %d].\t%d %% %d = ", num,d,e);
						scanf("%f", &ans);
						break;
		}
			
		/*shows the answer and score update in each question*/
		if (c==ans)
			{	score++;
				printf("\t\tGood! The answer is %.3f.\t(Score: %.0f)\n", c,score);
				puts("");
			}
		else
			{	printf("\t\tWrong! The answer is %.3f.\t(Score: %.0f)\n", c,score);
				puts("");
			}
		
	}
	
	ratio=(score/items)*100;
	puts("");
	printf("You got %.0f out of %.0f questions = %.2f%%\n", score,items,ratio);
	
	if (ratio==0.00)
		{printf("0 That%cs...just sad. Re-learn your math. ;___;\n", 39);
		}
	else if (ratio>0.00 && ratio<60.00)
		{printf("(0,60) That%cs awful. You need to practice your math. =(\n", 39);
		}
	else if (ratio>=60.00 && ratio<90.00)
		{printf("[60,90) Not bad. You can still do better though. :)\n");
		}
	else if (ratio<=90.00 && ratio<100.00)
		{printf("[90,100) You%cre almost there! ^o^\n", 39);
		}
	else
		{printf("100 That's what I'm talking about! ^_^\n");
		}

	puts("");
	if (ratio<60.00)
		ascii_fail();
	else if (ratio>=60.00 && ratio<100.00)
		ascii_good();
	else if (ratio==100.00)
		ascii_perfect();
		
	printf("Finished in %.0f seconds.", difftime(end, start));
	
				
	return 0;
}

this is the basis of my code.another code i made that is functional.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void ascii_fail(void)
{
	printf("     /%c__%c         /%c  %c\n", 92,92,92,92);
	printf("    /:/ _/_       /::%c  %c       ___ \n", 92,92);
	printf("   /:/ /%c__%c     /:/%c:%c  %c     /%c__%c\n", 92,92,92,92,92,92,92);
	printf("  /:/ /:/  /    /:/ /::%c  %c   /:/__/      ___     ___\n", 92,92);
	printf(" /:/_/:/  /    /:/_/:/%c:%c__%c /::%c  %c     /%c  %c   /%c__%c\n", 92,92,92,92,92,92,92,92,92);
	printf(" %c:%c/:/  /     %c:%c/:/  %c/__/ %c/%c:%c  %c__  %c:%c  %c /:/  /\n", 92,92,92,92,92,92,92,92,92,92,92,92);
	printf("  %c::/__/       %c::/__/       ~~%c:%c/%c__%c  %c:%c  /:/  /\n", 92,92,92,92,92,92,92,92);
	printf("   %c:%c  %c        %c:%c  %c          %c::/  /   %c:%c/:/  /\n", 92,92,92,92,92,92,92,92,92);
	printf("    %c:%c__%c        %c:%c__%c         /:/  /     %c::/  /\n", 92,92,92,92,92,92,92);
	printf("     %c/__/         %c/__/         %c/__/       %c/__/\n", 92,92,92,92);
}

void ascii_good(void)
{	printf(" .88888.                          dP dP\n");
	printf("d8'   `88                         88 88\n");
	printf("88        .d8888b. .d8888b. .d888b88 88\n");
	printf("88   YP88 88'  `88 88'  `88 88'  `88 dP\n");
	printf("Y8.   .88 88.  .88 88.  .88 88.  .88\n");
	printf(" `88888'  `88888P' `88888P' `88888P8 oo\n");
	printf("oooooooooooooooooooooooooooooooooooooooo\n");

}

void ascii_perfect(void)
{	printf("  ____   U _____ u   ____     _____U _____ u   ____  _____   _\n");
	printf("U%c  _%c\\ u\\%c ___%c%c/U %c  _%c\\ u %c%c ___%c%c ___%c%c/U /%c___%c%c_ %c _%cU%c%c%cu\n", 124,34,124,34,124,124,34,124,34,124,124,34,124,34,124,124,34,124,124,34,124);  
	printf("\\%c %c_) %c/ %c  _%c%c   \\%c %c_) %c/U%c %c_  u%c  _%c%c  \\%c %c u    %c %c  \\%c %c/\n", 124,124,124,124,124,34,124,124,124,124,124,124,124,34,124,124,124,124,124,124);
	printf(" %c  __/   %c %c___    %c  _ <  \\%c  _%c/ %c %c___   %c %c/__  /%c %c\\  %c_%c\n", 124,124,124,124,124,124,124,124,124,124,124,124,124,124);
	printf(" %c_%c      %c_____%c   %c_%c \\_\\  %c_%c    %c_____%c   \\____%cu %c_%cU  (_)\n", 124,124,124,124,124,124,124,124,124,124,124,124,124);
	printf(" %c%c>>_    <<   >>   %c%c   \\_) (  \\,- <<   >>  _%c%c  \\ _%c%c \\_  %c%c%c_\n", 124,124,47,47,47,47,47,47,124,124,124);  
	printf("(__)__)  (__) (__) (__)  (__)__)(_/(__) (__)(__)(__)__) (__)__)_)\n");
}


int main(void)
{
	int a,b;
	int sum, ans, count=0, num;
	float ratio, score=0, items;
	time_t start, end;
	
	puts("\t\tAddition Drills");
	puts("\tPutting your math skills to the test");
	puts("");
	printf("Enter number of items: ");
	scanf("%f", &items);
	puts("");
	
	start = time(0);
	
	for(count=0; count!=items; count++)
	{
		num=count+1;
		
		srand(time(NULL));
		a=rand()%100+1;
	
		srand(time(NULL)+1);
		b=rand()%100+1;
	
		sum=a+b;
	
		printf("\tQuestion %d]. %d + %d = ", num,a,b);
		scanf("%d", &ans);
		
		if (ans==sum)
			{
				score++;
				printf("\t\tGood!\t(Score: %.0f)\n", score);
				puts("");
			}
		else
			{
				printf("\t\tWrong!\t(Score: %.0f)\n", score);
				puts("");
			}
			
	}
	
	end = time(NULL);
	
	ratio=(score/items)*100;
	puts("");
	printf("You got %.0f out of %.0f questions = %.2f%%\n", score,items,ratio);
	
	if (ratio==0.00)
		{printf("0 That%cs...just sad. Re-learn your math. ;___;\n", 39);
		}
	else if (ratio>0.00 && ratio<60.00)
		{printf("(0,60) That%cs awful. You need to practice your math. =(\n", 39);
		}
	else if (ratio>=60.00 && ratio<90.00)
		{printf("[60,90) Not bad. You can still do better though. :)\n");
		}
	else if (ratio<=90.00 && ratio<100.00)
		{printf("[90,100) You%cre almost there! ^o^\n", 39);
		}
	else
		{printf("100 That's what I'm talking about! ^_^\n");
		}

	puts("");
	if (ratio<60.00)
		ascii_fail();
	else if (ratio>=60.00 && ratio<100.00)
		ascii_good();
	else if (ratio==100.00)
		ascii_perfect();
		
	printf("Finished in %.0f seconds.", difftime(end, start));
	
	
	return 0;
}

answer me asap.tnx.=)

Move line 61 up outside that loop. srand() should only be called once during the lifetime of the program.

Delete line 64. see above comment.

Move line 61 up outside that loop. srand() should only be called once during the lifetime of the program.

Delete line 64. see above comment.

>>sir, line 64? are you sure? there's nothing in line 64.please clarify it. i badly need everyone's help.thanks.^^

He's talking about the line numbers in your second program. Whichever one you are working with, get rid of all but one srand() call, which should be situated anywhere before the first call to rand() -- but preferably at the top of the program.

Even this line needs some correection:

scanf("&d", &items);

In your second program, why do you think

float ratio, score=0, items;

the number of items should be in floats.The reason why i ask is this:

for(count=0; count!=items; count++)

Mixing integers and floats may lead to unpredictable results.

commented: Good points +18
commented: Agree +25
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.