Solved programming problem

Find The total digit in input and product of those digit in C

Source code

#include <stdio.h>

int main()

{

    int n;

    int count=0;

    int sum=1;

    int b;

    printf("
Please Enter a digit:");

    scanf("%d",&n);

    do

    {

        b=n%10;

        sum=sum*b;

        n=n/10;

        count++;

    }while(n!=0);

    printf("
Total digits:%d
",count);

    printf("The Sum of the number:%d
",sum);

    return 0;

}

Output

Please Enter a digit:1234

Total digits:4

The Sum of the number:24

Join the discussion

Add your comment