SCE

Write a C++ program that find the sum of all even numbers between 1 and 30 excluding 6, 8, 24 and 28

###### Posted by Samath

Last Updated:
November 02, 2014

With the aid of a while loop create a C++ program that finds the sum all the even numbers between 1 and 30. Do not include the numbers 6, 8, 24 and 28 in the final accumulation of these even numbers.

Here is the Solution to the problem above:

#include <iostream> using namespace std; int main(int argc, char *argv[]) { int count = 1, sum = 0; while (count < 30) { if(count % 2 == 0) { if(count!=6 && count!=8 && count!=24 && count!=28) { sum += count; } } count ++; } cout<<"Result: "<<sum; cout<<endl; return 0; }