#include<stdio.h>
#include<stdlib.h>
int main()
{

    int **a,r,c,i,j,;
    printf("\n enter the size of row");
    scanf("%d",&r);
    printf("\n Enter the size of col");
    scanf("%d",&c);
    //allocating memory
    a = (int**)malloc (r*sizeof(int*));
        for(i = 0;i<r;i++)
            a[i] = (int*)malloc(c*sizeof(int));
            //array elements
            for(i = 0;i<r;i++)
            for(j = 0j<c;j++)
                scanf("%d",&a[i][j]);
                --------
                ---------

how to fill the array with random numbers

instead of scanf() call rand()

a[i][j] = rand();

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.