Computer Science, asked by RidaMaheshwari, 2 months ago

write an algorithm to enter a number and print the product of its digits​

Answers

Answered by garimakumari5469
1

Answer:

C program to find the product of digits of a number using a loop:

#include<stdio.h>

int main()

{

int num, rem, prod = 1;

printf("Enter a number: ");

scanf("%d", &num);

while(num != 0)

{

Answered by mahesijjh
1

Algorithms:

  • Ask the user to enter any number.
  • Declare and initialize another variable ‘prod’ with 1, where prod is an integer variable.
  • Get the last digit of the given number by performing the modulo division (%) and store the value in last_digit variable, likey last_digit= number % 10.
  • Multiply the last digit (last_digit) found above with prod i.e. prod= prod* last_digit.
  • Remove last digit by dividing the number by 10 i.e. num = num / 10.
  • Repeat steps 3-5 until the number becomes 0. In the last, you will get the product of the digits of the input number.

Similar questions