Generate random numbers

  • File name: Generate random numbers
  • Size: 267 b
yes /


The general code random numbers between 12 and 35 included and stored in a vector by rand () function and srand (time (NULL)).
You need to include the time.h library

#include <stdio.h>
#include <time.h>

int main(){
    int v[20];int i;
        v[i]=12+rand()%(35-12+1);printf("%d ",v[i]);
        //Variable = limite_inferior + rand() % (limite_superior + 1 - limite

return 0;


More exercises in


No ratings yet - be the first to rate this.

Add a comment