#include #include const int M=-1 ; int main() { int x, r ; int s=0 ; printf("entrez une valeur entiere \n") ; r = scanf ("%d", &x) ; // we simply check that the return value of scanf is 1 // (the expected number of correctly read input value) if (r!=1) exit(1) ; // exit if scanf failed to read an integer value while (x != M) { s = s + x ; printf("entrez une valeur entiere \n") ; r = scanf ("%d", &x) ; // we simply check that the return value of scanf is 1 // (the expected number of correctly read input value) if (r!=1) exit(1) ; // exit if scanf failed to read an integer value } ; printf("le resultat est %d \n", s) ; return 0 ; }