hi
i am trying to create the magic box of 3*3 using the random function
here is my code.....
Code:
# include<stdio.h>
# include<conio.h>
main()
{
int i,a[9];
for(i=1;i<=9;i++)
{
a[i]=rand();
}
while (true)
{
if((a[0]+a[1]+a[2]==15)&&(a[3]+a[4]+a[5]==15)&&(a[6]+a[7]+a[8]==15)&&(a[0]+a[4]+a[8]==15))
{
for(i=0;i<9;i++)
{
printf("%d ",a[i]);
printf("\n");
}
}
else
continue;
}
}
how to use the random function of c to put the values in the array?? and when i execute it says unidentified true symbol.....wat should i do???
in case the condition is not satisfied then how should i continue so that it generates random again????
thanks