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 :: how to checkout branch from commit id 
C :: mariadb utf8mb4 
C :: C read a character 
C :: c program strtok use 
C :: c print char 
C :: uuidv4 javascript 
C :: read string with space c 
C :: c if else 
C :: c for loop 
C :: implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration] 
C :: add a item to cart woocomerce with quantity 
C :: c substring 
C :: celsius to fahrenheit formula 
C :: Write a C program to merge two array to third array. 
C :: create role in psql with password 
C :: why there is return 0 used in c 
C :: latex remove page number from footer 
C :: adjacency matrix representation maker 
C :: number pattern in c 
C :: c include delay 
C :: terraform fargate cpu 
C :: powershell search big files 
C :: print only last 3 number float in c 
C :: binary sorting 
C :: scopes in c 
C :: stack pop 
C :: insse suprafata arabila pe ani 
C :: c to assembly converter 
C :: router solicitation and advertisement magic is used by 
C :: instller acrobat ous ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =