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
20 ответов
+ 3
Plz show your efforts on this task
This looks like a homework problem
+ 1
Ok I will try right now
+ 1
Thanks man it works
Thanks a lot
+ 1
You are welcome mate!!
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
}
0
Yep you now just multiply every no. With
d within the loop
d*=a;
0
Sorry but I don't understand
I must multiply the digits of my number
0
Within your loop
Keep multiplying the no. With d
And when the loops end print d
0
And what it will give me
0
One second
What you want your code to do?
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
0
You mean you want to multiply all the odd nos of those 10 given inputs?
0
For example number is 937
If 9*3*7=something which is odd number I must add it to other numbers
0
So you want to add all those nos whose digits , when multipled gives an odd no
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
0
I don't understand what you mean saying nos? ?
0
Numbers
0
int main() {
int p=1,n,r,s;
cin>>n;
while(n!=0){
r=n%10;
p=p*r;
n=n/10;
}
}
0
So the answer of your question is yes
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