Puzzle L9

Add up even, odd and all integers from 0 to N, except those integers divisible by 3 or 4

[E-13]Write a main() program that first asks the user for an integer, N, and then calculates three sums: the sum of the even integers, the sum of the odd integers, and the sum of all integers from 0 to N. However, exclued from these sums those integers that are divisible by 3 or divisible by 4. The output of the program is:

Enter n: 10
Sum = 25, Sum of Odd = 13, Sum of Even = 12

Use the previous program as the basis for this one.



Previous Page        Answer         Next Page         Home