Skip to content

Instantly share code, notes, and snippets.

@Azim
Created October 19, 2017 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Azim/0f9108543e268d2b4a41cf20b823f26c to your computer and use it in GitHub Desktop.
Save Azim/0f9108543e268d2b4a41cf20b823f26c to your computer and use it in GitHub Desktop.
Generate random array in C/c++
int array[MAX_ROWS][MAX_COLS];
srand(time(NULL));
printf("\n j j j j j");
for(int i=0;i<MAX_ROWS;i=i+1){
printf("\n \n i ");
for(int j=0;j<MAX_COLS;j=j+1){
array[i][j]=rand();
if(array[i][j]<10000){
array[i][j]+=10000;
}
printf("%d ",array[i][j]);
}
}
printf("\n");
@Azim
Copy link
Author

Azim commented Oct 19, 2017

Output:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment