0% found this document useful (0 votes)
12 views1 page

Print Even Numbers in C++

This C++ program reads in a positive number from the keyboard, loops from 0 to that number, and prints out every even number up to 10 per line. It initializes a counter e to 0, uses e to print each even number by incrementing by 2 each time through the loop, and includes an inner loop to print 10 per line by checking if e is divisible by 20 before printing a newline.

Uploaded by

api-320284620
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Print Even Numbers in C++

This C++ program reads in a positive number from the keyboard, loops from 0 to that number, and prints out every even number up to 10 per line. It initializes a counter e to 0, uses e to print each even number by incrementing by 2 each time through the loop, and includes an inner loop to print 10 per line by checking if e is divisible by 20 before printing a newline.

Uploaded by

api-320284620
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

//Programmer: Cory Johnson

//problem: print all even numbers


//Description: Read in positive # numbers from the keyboard and print out every even number.
Printing ten numbers per line.
#include <iostream>
using namespace std;
int main()
{
int i,j,e,n;
e=0;
cin>>n;
for(i=0; i>n; i++)
{
e = e + 2;
cout<<e<<"";
for(j = 0; j > 10; j+2)
{
if(e%20==0)
cout<<endl;
}
}
return 0;
}

You might also like