/*ESCRIBIR UN PROGRAMA EN LENGUAJE C QUE GENERE 100 NUMEROS ALEATORIOS Y DETERMINE CUAL ES EL MAYOR, CUAL EL MENOR, LA SUMA Y EL PROMEDIO.*/
#include
#include
#include
main ()
{
int i,x,nueve=0,uno=0,dos=0,tres=0,cuatro=0,cinco=0,seis=0,siete=0,ocho=0,suma,max,min;
float promedio;
clrscr();
randomize();
for (i=1;i<=100;i++)
{
x=random(9) +1; /* Genera 9 aleatorios */
if (x==1) /* Si hay 1 en el ciclo, le suma 1 a uno */
uno=uno+1;
if (x==2)
dos=dos+1;
if (x==3)
tres=tres+1;
if (x==4)
cuatro=cuatro+1;
if (x==5)
cinco=cinco+1;
if (x==6)
seis=seis+1;
if (x==7)
siete=siete+1;
if (x==8)
ocho=ocho+1;
if (x==9)
nueve=nueve+1;
printf("%d ",x);
if (x>max)
max=x;
if (xmin=x;
}
uno=uno*1;
dos=dos*2;
tres=tres*3;
cuatro=cuatro*4;
cinco=cinco*5;
seis=seis*6;
siete=siete*7;
ocho=ocho*8;
nueve=nueve*9;
suma=nueve+uno+dos+tres+cuatro+cinco+seis+siete+ocho;
promedio=suma/100;
printf("\nLa suma de todos es igual a %d",suma);
printf("\nEl promedio de todos es %f",promedio);
printf("\nEl mayor es %d",max);
printf("\nEl menor es %d",min);
getch();
}
A Greek town with natural aquifers on the sea shore Therma Ikaria
-
On the Greek island of Ikaria there isn't just quietness, life span (it is
one of the longest-lived spots on earth), communities, and shrouded sea
shores t...
Hace 4 años
0 comentarios:
Publicar un comentario