C-programming is the base of Computer programming.
This comment has been removed by the author.
#include stdio.h>int main(){ int k,n,p,r,prod1=1,prod=1,sum=0,sum1=0,i=0,digit;printf("\nEnter a non negative integer: "); scanf("%d",&n); if (n<10) { prod=n; sum=n; digit=1; } else { do { k=n%10; p=n-k; r=p/10; prod1=prod1*k; sum1=sum1+k; n=r; i++; } while(r>9); prod=prod1*r; sum=sum1+r; digit=i+1; } printf("\n\nproduct of digit: %d\n\nsum of digit: %d\n\nnumber of digit: %d\n",prod,sum,digit); return 0;}
while r>9 why u used
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete#include stdio.h>
ReplyDeleteint main()
{ int k,n,p,r,prod1=1,prod=1,sum=0,sum1=0,i=0,digit;
printf("\nEnter a non negative integer: ");
scanf("%d",&n);
if (n<10)
{
prod=n;
sum=n;
digit=1;
}
else
{
do
{
k=n%10;
p=n-k;
r=p/10;
prod1=prod1*k;
sum1=sum1+k;
n=r;
i++;
}
while(r>9);
prod=prod1*r;
sum=sum1+r;
digit=i+1;
}
printf("\n\nproduct of digit: %d\n\nsum of digit: %d\n\nnumber of digit: %d\n",prod,sum,digit);
return 0;
}
while r>9 why u used
Deletewhile r>9 why u used
Delete