0

Multiply the number digits

Creat a program that imports 10 natural numbers from the keyboard and determines the sum of the numbers the digit of which is an odd number This is the task My problem is in multipling the number digits

13th Jan 2019, 4:39 PM
Arsen
20 Answers
+ 3
Plz show your efforts on this task This looks like a homework problem
13th Jan 2019, 5:25 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 1
Ok I will try right now
13th Jan 2019, 6:58 PM
Arsen
+ 1
Thanks man it works Thanks a lot
13th Jan 2019, 7:07 PM
Arsen
+ 1
You are welcome mate!!
13th Jan 2019, 7:08 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
0
#include <iostream > using namespace std; Int main (){ int a, d=1, k=0; for (int i= 0; i < 10; i++){ cin>>a; After that I have some ideas I know who get the first and last digits. But nothing else }
13th Jan 2019, 6:20 PM
Arsen
0
Yep you now just multiply every no. With d within the loop d*=a;
13th Jan 2019, 6:27 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
0
Sorry but I don't understand I must multiply the digits of my number
13th Jan 2019, 6:31 PM
Arsen
0
Within your loop Keep multiplying the no. With d And when the loops end print d
13th Jan 2019, 6:34 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
0
And what it will give me
13th Jan 2019, 6:38 PM
Arsen
0
One second What you want your code to do?
13th Jan 2019, 6:40 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
0
Multiply the number digits Creat a program that imports 10 natural numbers from the keyboard and determines the sum of the numbers the digit of which is an odd number This is the task
13th Jan 2019, 6:41 PM
Arsen
0
You mean you want to multiply all the odd nos of those 10 given inputs?
13th Jan 2019, 6:44 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
0
For example number is 937 If 9*3*7=something which is odd number I must add it to other numbers
13th Jan 2019, 6:44 PM
Arsen
0
So you want to add all those nos whose digits , when multipled gives an odd no
13th Jan 2019, 6:47 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
0
I mean that I must import 10 natural numbers and cout the sum of the numbers if the multiply the digits of my number is odd
13th Jan 2019, 6:50 PM
Arsen
0
I don't understand what you mean saying nos? ?
13th Jan 2019, 6:54 PM
Arsen
0
Numbers
13th Jan 2019, 6:55 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
0
int main() { int p=1,n,r,s; cin>>n; while(n!=0){ r=n%10; p=p*r; n=n/10; } }
13th Jan 2019, 6:56 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
0
So the answer of your question is yes
13th Jan 2019, 6:56 PM
Arsen
0
p will give you the product of digits Now check it whether it is odd or not And add them if they are odd Hope this helps
13th Jan 2019, 6:57 PM
Saurabh Tiwari
Saurabh Tiwari - avatar