Coding in C :

#include <stdio.h>
#include<conio.h>
int main()
{
//Declaration of variables
    int n;
    int dig, sum,pro;
    
    //Input any number from the user

    printf("\nEnter an integer number :");
    scanf("%d",&n);
 
//Compute sum and product of the digit.
    sum=0;
    pro=1;
    
    while(n>0)
    {
        dig=n%10;
        sum+=dig;
        pro*=dig;
        n=n/10;
    }
   //Display the  sum and product of the digit.

    printf("\nSUM of all Digits is : %d",sum);
    printf("\nPRODUCT of all digits: %d",pro);  
    return 0;
    getch();
}

Output :
Enter an integer number : 89

SUM of all Digits is : 17
PRODUCT of all digits: 72

0 comments:

Post a Comment