Write a program to count and print even values between 0 and 20:
Sample Output
The Total even numbers between 0 and 20 exclusives is 10
#include <iostream>
using namespace std;
int main()
{
int lower = 0;
int upper = 20;
int count = 0;
for (int i = lower; i < upper; i++)
{
if (i % 2 == 0)count++;
}
cout << "Total even numbers between 0 and 20 exclusives is " << count;
}
Comments
Leave a comment