need a cooment for looping

N

noobc++

i have a problem in displaying the even value. i try to do the exercise
in asking the user of the value of x and the value of y. then, showing
the value bettween x and y. in between the value x and y there suppose
to be an even and odd number.
for exampe if the value x = 1 and the value of y = 5. then it will
write 12345. (i done this). but, i have the problem in showing the even
value between x and y . i use for loops for showing the 12345 and then
i confused for showing the even value. i know the formula would be
value*2..
 
L

lw1a2

#include <iostream>
using namespace std;

void foo(int low, int high)
{
for (int i=low; i<=high; ++i)
if ((i%2)==0) cout<<i;
cout<<endl;
}

int main()
{
foo(1, 5);
system("pause");
return 0;
}
 
H

Howard

lw1a2 said:
#include <iostream>
using namespace std;

void foo(int low, int high)
{
for (int i=low; i<=high; ++i)
if ((i%2)==0) cout<<i;
cout<<endl;
}

int main()
{
foo(1, 5);
system("pause");
return 0;
}

How about not just doing others' homework for them, eh? How's he supposed
to learn anything if all his answers are simply handed to him? Do you want
to work with some idiot who passed his courses simply by asking others to do
their work?

-Howard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,800
Messages
2,569,657
Members
45,417
Latest member
BonitaNile
Top