Advertisement
Xioth

C - TP1 - sommePair.c

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