Advertisement
gtw7375

NUMEROS PARES E IMPARES - C

Sep 1st, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.35 KB | None | 0 0
  1. main() {
  2.  
  3.     int i, num;
  4.     float contI=0;
  5.     float contP=0;
  6.     float par=0;
  7.     float imp=0;
  8.     float mediaP=0;
  9.     float mediaI=0;;
  10.    
  11.    
  12.         for(i=0; i<4; i++) {
  13.            
  14.             printf("Digite um numero \n");
  15.             scanf("%d", &num);
  16.            
  17.                  if(num %2 == 0) {
  18.                                    
  19.                             par += num;
  20.                             contP += 1;
  21.                     }  else  {
  22.                
  23.                             imp +=num;
  24.                             contI += 1;
  25.                      }
  26.            
  27.          }
  28.                    
  29.                    mediaP = par / contP;
  30.                    mediaI = imp / contI;
  31.        
  32.                     printf("\n MEDIA PAR %f", mediaP);
  33.                     printf("\n \n MEDIA IMPAR %f", mediaI);
  34.                    
  35.                     printf("\n \n  QUANTIDADE DO PAR %f", par);
  36.                     printf("\n \n QUANTIDADE DO IMPAR %f", imp);
  37.            
  38.              
  39.              
  40.                if(contI > contP) {
  41.                  
  42.                             printf("\n \n O maior e o impar\n");
  43.                
  44.                   } else {
  45.                          
  46.                             printf("\n \n O maior e o par\n");
  47.                     }
  48.                
  49.     system("pause");
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement