LOVEGUN

Divisibilité par 5 somme (Série ISI)

Oct 11th, 2021 (edited)
93
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 a,b,i,s;
  7.     do{
  8.         printf ("Saisir a: ");
  9.         scanf ("%d",&a);
  10.         printf ("\nSaisir b: ");
  11.         scanf ("%d",&b);
  12.     }while(a<0 || b<0 || a==b || a>b);
  13.     s=0;
  14.     for (i=a;i<=b;i++)
  15.     {
  16.         if (i%5==0)
  17.         {
  18.             s=s+i;
  19.         }
  20.     }
  21.     printf ("La somme des entiers divisibles par 5 dans l'intervalle [%d,%d] est %d",a,b,s);
  22. }
  23.  
Add Comment
Please, Sign In to add comment