bouchnina

Untitled

Jan 3rd, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int nbr,sommePos=0,sommeNeg=0,nbrPos=0,nbrNeg=0;
  7.     float moyPos,moyNeg;
  8.  
  9.     do{
  10.         printf("Entrer un nombre (Zero pour finir) :");
  11.         scanf("%d",&nbr);
  12.         if(nbr>0)
  13.             {
  14.                 nbrPos++;
  15.                 sommePos+=nbr;
  16.             }
  17.         if(nbr<0)
  18.             {
  19.                 nbrNeg++;
  20.                 sommeNeg+=nbr;
  21.             }
  22.         }while(nbr!=0);
  23.     moyPos=(float)sommePos/nbrPos;
  24.     moyNeg=(float)sommeNeg/nbrNeg;
  25.     printf("on a %d nombres positifs :  \n",nbrPos);
  26.     printf("\t somme des nombres positifs : %d \n",sommePos);
  27.     printf("\t moyenne des nombres positifs : %f \n",moyPos);
  28.     printf("on a %d nombres negatifs :  \n",nbrNeg);
  29.     printf("\t somme des nombres negatifs : %d \n",sommeNeg);
  30.     printf("\t moyenne des nombres negatifs : %f \n",moyNeg);
  31.     system("pause");
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment