fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int maximum, count, sum;
  5. count = 0;
  6. sum = 0;
  7.  
  8. printf("Enter maximum number: \n");
  9. scanf("%d", &maximum);
  10.  
  11. while(count <= maximum) {
  12. if (count % 3 == 0) {
  13. sum = sum + count;
  14. }
  15. count = count + 1;
  16.  
  17. }
  18.  
  19. printf("The sum of all multiples of three is %d.", sum);
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 10320KB
stdin
30
stdout
Enter maximum number: 
The sum of all multiples of three is 165.