i want to generate random no. every time i execute the program and generated random sequence should not be identical. here the program i created , generates random sequence and the problem is the generated random sequence is identical every time i execute the program.
#include<stdio.h>
#include<time.h>
#include <stdlib.h>
int main()
{
time_t t1,t2;
time(&t1);
time(&t2);
int a,b,r,s,score=0,right=0,wrong=0;
while(t2-t1<100)
{
a=rand()%100; // generate random values 0 to 99
b=rand()%100;
r=a+b;
printf("%d + %d = ",a,b);
scanf("%d",&s);
if(s==r)
{
score=score+10;
right++;
printf(" Right!\n");
}
else
{
score=score-10;
wrong++;
printf(" Wrong!\n");
}
time(&t2);
}
printf("Your score is %d \n right = %d \n wrong = %d\n",score,right,wrong);
}
Every time i execute the program , generate same sequence 41+67= , 34+0= , 69+24= , 78+58= , ... .
i want this program to generate different expressions ,every time it executes, i don't know how to resolve this issue.