19 March, 2012

C++ Program To Find & Print A Strong Number.

This Post Contains A C++ Program To Find & Print A Strong Number With Correct Source Code & Output. This Program Is Written, Compiled & Executed At TurboC3.0 Compiler & Will Help You To Understand The Concept Of 'While-loop', 'If...else' & 'Nested Loops' From C++ Language. It Is A Well-Structured Program With Proper Comments Which Provides Step-By-Step Description Of Various Features Of The Language In A Simple & Easy-To-Understand Way.


# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.


C++ Program To Find & Print A Strong Number.

# include <iostream.h>
# include <conio.h>

void main()
{
   int Num, s, r, f, t;
   clrscr();
   cout << " Enter Any Number : ";
   cin >> Num;
   t  =  Num;
   s  =  0;
   while ( Num   >   0 )
   {
      r  =  Num  %  10;
      f  =  1;
      while (  r  >  0  )
      {
         f  =  f  *  r;
         r--;
      }
      s  =  s  +  f;
      Num  Num  /  10;
   }
   if (  s  ==  t)
   {
      cout << t << " Is A Strong Number.";
   }
   else
   {
      cout << t << " Is Not A Strong Number.";
   }
   getch();
}

Output :

Enter Any Number : 145

145 Is A Strong Number.




No comments:

Post a Comment

Subscribe To:

Most Commonly Asked Programs In 'C' & 'C++' Language.