I am trying to printf a bounce of natural numbers (from 0 up to 10) using srand but when I run the code, it generate numbers with 7 digit. How is it possible? Can anybody tell me where I am doing wrong?
enter code here
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define DIMA 10
#define DIMB 2
int main()
{
int A[DIMA], B[DIMB], i, j, flag;
srand (time(NULL));
for (i=0; i< DIMA; i++);{
A[i]=rand() % 11;
}
for (i=0; i< DIMB; i++);{
B[i]=rand() % 11;
}
for (i=0; i<DIMA; i++){
printf("%d ", A[i]);
}
printf("\n\n");
for (i=0; i<DIMB; i++){
printf("%d ", B[i]);
}
return 0;
}
Thanks for support.
Aucun commentaire:
Enregistrer un commentaire