By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,191 Members | 751 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,191 IT Pros & Developers. It's quick & easy.

need a cooment for looping

P: n/a
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..

Sep 30 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
#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;
}

Sep 30 '06 #2

P: n/a
thank you
lw1a2 wrote:
#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;
}
Sep 30 '06 #3

P: n/a
thank's
lw1a2 wrote:
#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;
}
Sep 30 '06 #4

P: n/a

"lw1a2" <lw********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
#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

Oct 2 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.