Advertisement
Shailrshah

Sum & no. of numbers divisible by 7 b/w 100 and 200

Apr 18th, 2013
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.25 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     int n=100,count=0,sum=0;
  5.     do
  6.     {
  7.         if(n%7==0)
  8.         {
  9.             ++count;
  10.             sum += n;
  11.         }
  12.         n++;
  13.     } while(n!=200);
  14.     printf("Sum is %d and number is %d \n",sum,count);
  15.     return 0;
  16. }
  17. //Output
  18. //Sum is 2107 and number is 14
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement