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 <iostream.h>
int main()
{
int num1=1;
int num2=2
if(num1<num2
{
cout << num1<<num2*2endl;
num1=num1+1;
num2=num2*2;
}
return 0;
}

Can you help me with this. What do you think?
You help is appreciated.....Peter

You need a loop construct:

int i;

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

something like that outa work.

tortellini
you are a miricle..
thank you peter

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

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 <iostream.h>

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

if (num1=0; num2<100; num2=1=2){
cout<<
}
return 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 <iostream.h>

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

if( num1 = num2)
cout<<

return 0;
}

thats easy...

#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
     int x = 0;

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

return 0;
}

Bleek thank you....

Peter Brown

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");
}

for next time ;)

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 jayson144@gmail.com tnx

commented: You just bumped a thread 6 years old +0
commented: don't bump old posts. -2

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.