I've been assigned the task of writing a program which dinamically allocates n arrays of random sizes t, fills them with random values, finds the smallest and the largest elements and then prints out the module of their difference.
The value of n entered by the user must be in the range (5, 20], t should be generated in the range [10, 1000] and the range of the values used to fill those arrays should be [-10, 0].
This is my attempt:
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int main()
{
    int n,i,j,t,a[t],z,min=10000000,max=0;
    do
    {
        scanf("%d",&n);
    }
    while(n<=5 || n>20);
    for(i=0;i<n;i++)
    {
    t=(10)+rand()%(10-1000+1);
    a[t]=(int*)malloc(t*sizeof(int));  // <-- This generates an error
    for(j=0;j<t;j++)
    {
        a[t]=(-10)+rand()%(-10+1);
        if(a[t]<min) min=a[t];
        if(a[t]>max) max=a[t];
    }
    
    }
    printf("%d",z=abs(min-max));
    return 0;
    
}
The compiler only shows this error, but I'm not sure if the rest of the code is good.
15 6  C:\Users\x\asfag.cpp  [Error] invalid conversion from 'int*' to 'int' [-fpermissive]
What am I doing wrong?
 
     
    