This is a function to fill the array with random numbers. n
is the user input,p[n][n]
is the array I try to create.I wanna use 2 functions named fillPin2d
and showPin2d
in order one function to fill the array with random numbers and one to print the array.The program keeps asking to enter an integer and its doesn't show the array I created.
#include<stdio.h>
#include<stdlib.h>
void fillPin2d(int n,int p[n][n])
{
int i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
p[i][j]=rand()% 11;
}
void showPin(int n,int p[n][n])
{
int i,j;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
printf("%d\n",p[i][j]);
}
}
}
main() {
int n;
do {
printf("Enter an integer n>5: \n");
scanf("%d",&n);
}while(n<=5);
int p[n][n];
fillPin2d(n,p);
showPin(n,p);
system("pause");
}