Wednesday, 8 January 2014

C Program to print Product of Digits of a given number

/*
eg. 212=2*1*2=4
eg. 313=3*1*3=9
*/

#include<stdio.h>
#include<conio.h>
void main()
{
 int no,r,pt=1;
 clrscr();
 printf("Enter a no:");
 scanf("%d",&no);
 while(no>0)
 {
  r=no%10;
  pt=pt*r;
  no=no/10;
 }
 printf("Product of Digits= %d",pt);
 getch();
}

No comments:

Post a Comment