Sunday, 3 June 2012

C++ Program to extract maximum prime digit from a number

C++ Program to extract maximum prime digit from a number


#include<iostream.h>
#include<conio.h>
int mprime(int);
main()
{ int a,b;
  cout<<"enter a number:";
  cin>>a;
  b=mprime(a);
  cout<<b;
  getch();
  return 0;
}
  int mprime(int c)
  { int n,big=0,d,count=0,i;

    do{
       n=c%10;
       for(i=1;i<=n;i++)
     {
       if(n%i==0)
        count=count+1;
       if(c==2)
       { if(big<n)
          big=n;
          count=0;
       }
        d=d/10;
      }
      }
      while(c!=0);
       cout<<big<<"is the maximum digit number";
       return  big;
  }

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More