Advertisement
Xioth

C - TP1 - moyenne.c

Jan 17th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int userInput = 0, somme = 0, diviseur = 1;
  7.  
  8.     while (userInput != -1)
  9.     {
  10.         printf("Entrez un nombre : (-1 pour arreter)\n");
  11.         scanf("%d", &userInput);
  12.  
  13.         if(userInput != -1)
  14.         {
  15.             somme += userInput;
  16.  
  17.             printf("La moyenne des nombres entres est de : %d\n", somme/diviseur);
  18.  
  19.             diviseur++;
  20.         }
  21.     }
  22.  
  23.     system("pause");
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement