Write an algorithm and draw a flowchart to enter a number and print the product of the digits of the given number..
Answer it plz.
Share
Write an algorithm and draw a flowchart to enter a number and print the product of the digits of the given number..
Answer it plz.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Answer:
// C++ program to compute
// product of digits in the number.
#include<bits/stdc++.h>
using namespace std;
/* Function to get product of digits */
int getProduct(int n)
{
int product = 1;
while (n != 0)
{
product = product * (n % 10);
n = n / 10;
}
return product;
}
// Driver program
int main()
{
int n = 4513;
cout << (getProduct(n));
}
Output: 60
Explanation:
Algorithm:
start
initialize two variables a,b as int
input a,b, value from the user
start if a is equal to b the initialize sum as int
add a and b,store the value in sum variable
print sum
else initialize product as int
multiply a with b and store the result in product variable
print product
end if condition
end program
Hope its helpful for you.
Tell this to ma'am the moment she asks u 'bout this as informed 'bout your pleasing girl❤