0% found this document useful (0 votes)
10 views1 page

Random Number Generation in C

The document contains a C program that generates an array of 100 random integers between 15 and 150. It then processes these integers by multiplying odd-indexed values by their index and even values by 3. Finally, it prints the initial and processed values to the console.

Uploaded by

ivanpineyro978
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Random Number Generation in C

The document contains a C program that generates an array of 100 random integers between 15 and 150. It then processes these integers by multiplying odd-indexed values by their index and even values by 3. Finally, it prints the initial and processed values to the console.

Uploaded by

ivanpineyro978
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#include <stdio.

h>
#include <stdlib.h>
#include <time.h>
#define N 100

/*

*/

int main(int argc, char *argv[])


{
int VN[N];
srand(time(NULL));
int ind;
for(ind=0;ind<N;ind++)
{
VN[ind]=rand()%(150-15+1)+15;
}

//muestro los valores


printf("\n*********Valores Randomicos**********\n");
for(ind=0;ind<N;ind++)
{
printf("%d\t",VN[ind]);
}
printf("\n*********Proceso segun pautas**********\n");
for(ind=0;ind<N;ind++)
{
if(ind%2!=0)
{
VN[ind]*=ind;
}
if(VN[ind]%2==0)
{
VN[ind]*=3;
}

}
printf("\n*********Valores Finales**********\n");
for(ind=0;ind<N;ind++)
{
printf("%d\t",VN[ind]);
}

return 0;
}

You might also like