fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int n, rem, product = 1, found = 0;
  5. printf("Enter a number: \n");
  6. scanf("%d", &n);
  7.  
  8. while (n > 0) {
  9. rem = n % 10;
  10. if (rem % 2 != 0) {
  11. product *= rem;
  12. found = 1;
  13. }
  14. n /= 10;
  15. }
  16.  
  17. if (found)
  18. printf("Product of odd digits = %d\n", product);
  19. else
  20. printf("No odd digits found\n");
  21.  
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0.01s 5288KB
stdin
12345
stdout
Enter a number: 
Product of odd digits = 15