How to use find the product of digits of any number in c language

Product of Digits

On this page

Product of Digits

Program to use Find the Product of Digits of any Number in C Language

#include <stdio.h>
  int main()
  {
    int n, prod = 1, rem;
    printf("enter a number : ");
    scanf("%d", &n);
    while (n > 0)
    {
        rem = n % 10;
        prod *= rem;
        n /= 10;
    }
    printf("Product of Digits = %d\n", prod);
    return 0;
  }
  

Output

Enter a Number : 166
  Product of Digits = 36