jeudi 27 avril 2017

C - How to generate random numbers between 20 and 30? [duplicate]

I've tried but it doesn't seem to give me the desired numbers. Here's my code so far:

#include <stdio.h>
#include <stdlib.h>

int main()
{
   int n, i;
   printf("Value of n:\n");
   scanf("%d", &n);
   int t[n];
   for(i=0; i<n; i++)
    printf("%d ", rand()%20+30);

return 0;
}




Aucun commentaire:

Enregistrer un commentaire