this a binggo game but im stuck with checking the numbers in the loop.
i need an output that display a different random numbers without repeating any number.
i made a checking function but I'm not sure if it is applicable to this program.
can anyone help me with this program,

Code: c++
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<time.h>
int x[5][5];
int CheckIfExist(int num)
{
int flag = 0, i, j;
for (i=0;i<5;i++)
for(j=0;j<5;j++)
if (x[i][j]==num) {
flag = 1;
break;
}
return flag;
}

main()
{
int xx, ctr=0, b=0, i=0, n=0, g=0, o=0, w, q;
clrscr();

for(;;) {
xx=random(75)+1;
if(CheckIfExist(xx)==0) {
if (xx>=1 && xx<16) {
x[0][b]=xx;
b++;
ctr++;
}
if (xx>=16 && xx<31) {
x[1][i]=xx;
i++;
ctr++;
}
if (xx>=31 && xx<46) {
x[2][n]=xx;
n++;
ctr++;
}
if (xx>=46 && xx<61) {
x[3][g]=xx;
g++;
ctr++;
}
if (xx>=61 && xx<76) {
x[4][o]=xx;
o++;
ctr++;
}
}
if(ctr>24)
break;
}

for(w=0;w<5;w++)
for(q=0;q<5;q++) {
gotoxy((w*3)+1,q+1);
printf("%d",x[w][q]);
}

getch();
return 0;
}

Last edited by SaswatPadhi; 18Aug2009 at 12:55.. Reason: Code-Blocks