954,132 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Print Even Numbers

I have a problem, I want to create a program in C++.
A simple program displaying all even number between 1 and 100, (such as 2, 4, 6, 8 etc.) in an out put. Can you tell me what wrong. Something like this.
#include
int main()
{
int num1=1;
int num2=2
if(num1

peter brown
Newbie Poster
8 posts since Apr 2004
Reputation Points: 12
Solved Threads: 0
 

You need a loop construct:

int i;

for (i = 0; i <= 100; i += 2) {
//print i
}

something like that outa work.

tortellini
Newbie Poster
1 post since Apr 2004
Reputation Points: 11
Solved Threads: 0
 

tortellini
you are a miricle..
thank you peter

peter brown
Newbie Poster
8 posts since Apr 2004
Reputation Points: 12
Solved Threads: 0
 

The C++ program I wanted you to help me with

peter brown
Newbie Poster
8 posts since Apr 2004
Reputation Points: 12
Solved Threads: 0
 

I need help in creating a C++ program, to display all even numbers between 1 and 100, (such as 2, 4, 6, 8 etc). The program would go something like:

#include

int main ( )
{
int num1=1;
int num2=2;

if (num1=0; num2<100; num2=1=2){
cout<<
}
return 0;
}

peter brown
Newbie Poster
8 posts since Apr 2004
Reputation Points: 12
Solved Threads: 0
 

Hello, Iam trying to create a program, that would display all even number between 1 and 100, (such as 2,4,6,8 etc.). The program would be in C++, and it would go something like:

//comments
//date
#include

int main( )
{
int num1=0;
int num2=2*2;

if( num1 = num2)
cout<<

return 0;
}

peter brown
Newbie Poster
8 posts since Apr 2004
Reputation Points: 12
Solved Threads: 0
 

thats easy...

#include
#include
using namespace std;

int main()
{
int x = 0;

while (x < 101)
{
cout << x << endl;
x = x + 2;
}
system("pause");

return 0;
}

Bleek
Light Poster
28 posts since Mar 2004
Reputation Points: 45
Solved Threads: 0
 

Bleek thank you....

Peter Brown

peter brown
Newbie Poster
8 posts since Apr 2004
Reputation Points: 12
Solved Threads: 0
 

if you wanted to go beyond the call of duty you could do one of these:

#include <iostream.h>
#include <stdlib.h>
void main()
{
 int MAX;
 cout<<"Enter a number to count by two to: ";
 cin>>MAX;
 for (int x = 0; x <= MAX; x++)
 {
  if (x % 2 == 0)
  {cout << x << endl;}
 }
 system("pause");
}
BountyX
Posting Whiz in Training
230 posts since Mar 2004
Reputation Points: 28
Solved Threads: 9
 

for next time ;)

Bleek
Light Poster
28 posts since Mar 2004
Reputation Points: 45
Solved Threads: 0
 

create a program that accepts an array of 5 integers. It will display the 5
integers entered blinkung all the even numbers


pls help me tnx! mail me [email]jayson144@gmail.com[/email] tnx

jayson144
Newbie Poster
1 post since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

Why did you bump a thread from 2004? Create your own thread if you needed help.

Akill10
Posting Pro
575 posts since Sep 2010
Reputation Points: 115
Solved Threads: 80
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You