Search
 
SCRIPT & CODE EXAMPLE
 

C

How to generate a random array in c

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

main(){
    int vet[1000], fre[50];
    int i;

    srand(time(NULL));

    for(i=0;i<1000;i++){
        vet[i]=(rand()%51);
    }

    for(i=0;i<1000;i++){
        printf("%d
", vet[i]);
    }

    for(i=0;i<1000;i++){
        fre[vet[i]]=fre[vet[i]]+1;
    }

    for(i=0;i<51;i++){
        printf("The number %d  was generated %d times
", i, fre[i]);
    }
}
Comment

C random array

int i;
for (i = 0; i < 100; i++) {
    my_array[i] = rand();
}
Comment

PREVIOUS NEXT
Code Example
C :: multiplication table using c 
C :: lsusb command not found 
C :: print 2d array in c 
C :: Calculator_C 
C :: how to declare a integer list on c 
C :: reattach screen linux 
C :: graphics in c 
C :: dynamically create matrix c 
C :: c program 
C :: count number of vowels in a string in c 
C :: sdl2 c programming 
C :: svg not loading in chrome 
C :: to find greatest of 4 numbers in c 
C :: fractional knapsack problem in c 
C :: for loop in c 
C :: Hello world in C programming language 
C :: c memset 
C :: c string to int 
C :: typescript class as function parameter 
C :: C first digit of integer 
C :: bootstrap 4 forms 
C :: c for 
C :: identifiers in c 
C :: what is c 
C :: KneesDev 
C :: powershell list big files 
C :: how to arrange a 2d array based on string length in c 
C :: while loop in c 
C :: static variable c 
C :: *= in c 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =