Tema: arrays y for
Ver Mensaje Individual
  #38 (permalink)  
Antiguo 10/04/2012, 13:14
alejandromi
 
Fecha de Ingreso: marzo-2012
Mensajes: 33
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: arrays y for

este lo hice con algun arreglo

Código:
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
 
int main()
{
system("color 0B");
char seguir;
int x[6];
int suma=0;
int multiplicar=1;
int mayor,i;
int resultado= 0;

for(;;)
{

printf("\n\t\t*** SUMA DE LOS 6 NUMEROS ***\n");

for(i=0; i<6; i++)
{
        printf("\nIntroduzca el numero entero y luego pulse intro:\t",i+1);
        scanf("%i",&x[i]);
        suma+=x[i];
        multiplicar*=x[i];
}
printf ("\n Suma= %i",suma);
 
 
printf("\n\t\t***  EL NUMERO MAYOR  ***\n");
mayor=x[0];
 
for (i=1 ; i<6 ; i++)
{
    if ( x[i]>mayor)
    {
    mayor=x[i];
    }
}
 
printf("\n El Mayor es: %d",mayor);
 
 
printf("\n\t\t***  LOS MULTIPLOS DE ELLOS  ***\n");
 
    for(i=0;i<6;i++)
    {
    if (x[i] % 2 == 0 ) printf("%d es multiplo de 2\n",x[i]);
    if (x[i] % 3 == 0 ) printf("%d es multiplo de 3\n",x[i]);
    if (x[i] % 5 == 0 ) printf("%d es multiplo de 5\n",x[i]);
    }
 
 
printf("\n\t\t***  MULTIPLICA LOS NUMEROS ***\n");

 
printf ("\n Resultado de Multiplicar= %i\n",multiplicar);
     
 
printf("\n\t\t***  LA RAIZ CUADRADA DE LA SUMA ***\n");
 

     
printf(" \n La raiz de la suma es %f\n" , sqrt( (float) suma ));
 


 
printf("\n Si desea otra vez pulse S/s y luego intro\n");
          scanf("%c",&seguir);
          fflush(stdin);
          if(seguir == 'S' || seguir == 's') system("cls");
          else break;
}
printf("\n\n");
system("pause");
return 0;    
}

Última edición por alejandromi; 10/04/2012 a las 14:36