Hi.I want to thank in advance for all replys.
Well let's get to the problem.
I need to a C++ code that will do the following:
1.User inputs a number
2.All digits of the number inputed not divisable by 2(odd numbers) must be multiplicated. (* operation ).
3.Show multiplication result.

Please give a reply till tomorrow.

Recommended Answers

All 5 Replies

Do you have anything as an attempt? It's fairly simple logic, I believe. Get the value of the input, assign it to a variable. Test to see if variable % 2 != 0. If true, then multiply, else ... whatever else u want to do to it... return... or whatever...

commented: you have the right attitude, carry on! +2

Do you have anything as an attempt? It's fairly simple logic, I believe. Get the value of the input, assign it to a variable. Test to see if variable % 2 != 0. If true, then multiply, else ... whatever else u want to do to it... return... or whatever...

i need to multiply the digits of the number that are dividable by 2.
Example :if the number is 257685 then :2*6*8=96
I don't know the algorithm of finding every number's digit.

i need to multiply the digits of the number that are dividable by 2.
Example :if the number is 257685 then :2*6*8=96
I don't know the algorithm of finding every number's digit.

I am assuming u want this:
given number x= 257685
u want to find the digits in separate way
like: i1=2, i2=5, i3=7, i4=6, i5= 8, i6=5

Here is my suggestion:
divide by 10, store the number, and continue dividing by 10
unless u hit upon zero.
like-> 257685/10 ->25768
25768/10 -> 2576
2576/10 -> 257
257/10-> 25
25/10 -> 2 <---- this is ur first digit.
any futher division will result zero
Now compare if that number i even or odd as required by ur task

and continue this process still u exhauste the set.

Hope it helps. :)

Hi.I want to thank in advance for all replys.
Well let's get to the problem.
I need to a C++ code that will do the following:
1.User inputs a number
2.All digits of the number inputed not divisable by 2(odd numbers) must be multiplicated. (* operation ).
3.Show multiplication result.

Please give a reply till tomorrow.

We don't do homework for people here. Try it out yourself and post up your code if you encounter any problems.

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.