PROGRAM TO FIND SUM AND PRODUCT OF ALL DIGITS OF A NUMBER

No comments


/* PROGRAM TO FIND SUM AND PRODUCT OF ALL DIGITS OF A NUMBER */


#include <stdio.h>
intmain()
{
int n;
int dig,sum,pro;
printf("\nEnter an integer number :");
scanf("%d",&n);

/*Calculating Sum and Product*/
    sum=0;
    pro=1;

while(n>0)
{
        dig=n%10;/*get digit*/
        sum+=dig;
        pro*=dig;
        n=n/10;
}
printf("\nSUM of all Digits is : %d",sum);
printf("\nPRODUCT of all digits: %d",pro);

return0;
}


Output :-



No comments :

Post a Comment

Subscribe

Milan Panda
Admin
About Me | Contact
Copyright 2023-2024 © Programming1011 . 🎀 Developed and Design By- Milan Panda. Happy Holi All Of You 🎀