I have to do this with "for" and "while" loop in c++ but no idea how

print all numbers between 10000 and 100 which are devisible with 5 and 9 but not with 2

any help suggestion advice or anything is needed urgently this is too complicated for me heelp

Recommended Answers

All 5 Replies

the only thing i have on mind is to do

    for(int i=10000;i>=100;i--){


    if()
}

but no idea how to do the conditions am i write or wrong

oh i did this1 but i have 2 more
1. add number with cin and and collect all even numbers lower than the entered number
2. enter 2 numbers x an y with cin and print all numbers between the x and y which r divisable with 3
suggestions pls

To divide You may apply the condition like :

if(i%5==0 && i%9==0)
{
}

&& operator will help you to execute this statement if both of the conditions are true otherwise it may execute the else part where u can place an invalid message if the number is divisble by 2.

void display()
{
for (int i=100;i<100001;i++)
{
if (i%5==0 %% i%9==0)
cout<<i<<endl;
}
}

basit_3: While it is admirable that you want to help the OP out with the problem, it is generally not advisable to simply give the working code out willy-nilly, especially without any explanation. DaniWeb policy generally to give advice rather than solving problems outright.

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.