Generate random numbers

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

Download

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;
    srand(time(NULL));
    for(i=0;i<20;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 https://www.youtube.com/channel/UCK05KbyByXPCMRJEqyL4VXw/videos

 

No ratings yet - be the first to rate this.

Add a comment

You're using an AdBlock like software. Disable it to allow submit.