This Post Contains A C Program To Find & Print A Strong Number With Correct Source Code & Output. This Program Is Written, Compiled & Executed At TurboC/C++3.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.
/* Declaration Of Header Files */
# include < stdio.h >
# include < conio.h >
/* Start Of Main Program */
void main()
{
/* Declaration Of Variables */
int Num, s, r, f, t;
clrscr();
/* Asking For The Input From User */
printf ( " \n Enter Any Number : " );
scanf ( " %d ", &Num );
/* Source Code For Computing Strong Number */
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();
}
/* End Of Main Program */
Output :
Enter Any Number : 145
145 Is A Strong Number.
# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.
C Program To Find & Print A Strong Number.
/* Declaration Of Header Files */
# include < stdio.h >
# include < conio.h >
/* Start Of Main Program */
void main()
{
/* Declaration Of Variables */
int Num, s, r, f, t;
clrscr();
/* Asking For The Input From User */
printf ( " \n Enter Any Number : " );
scanf ( " %d ", &Num );
/* Source Code For Computing Strong Number */
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();
}
/* End Of Main Program */
Output :
Enter Any Number : 145
145 Is A Strong Number.
No comments:
Post a Comment