This Post Contains A C Program To Find & Print An Armstrong 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' 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 An Armstrong Number.
/* Declaration Of Header Files */
# include < stdio.h >
# include < conio.h >
/* Start Of Main Program */
void main()
{
/* Declaration Of Variables */
int Num = 0, s, r, t;
clrscr();
printf ( " \n Enter Any Number : " );
scanf ( " %d ", &Num );
t = Num;
s = 0;
while ( Num > 0 )
{
r = Num % 10;
s = s + ( r * r * r );
Num = Num / 10;
}
if ( s == t )
{
printf ( " \n %d Is An Armstrong Number.", t );
}
else
{
printf ( " \n %d Is Not An Armstrong Number.", t );
}
getch();
}
/* End Of Main Program */
Output :
Enter Any Number : 153
153 Is An Armstrong Number.
This blog provides an overview about basic structure of C/C++ programs and their execution, which makes it an ideal guidance source for Programmers and Students. Based on practical approach this blog features a wide range of programs, which enables the learner to understand the techniques such as: Simple Programs, Loops, Arrays, Functions, Objects, Operator Overloading, Polymorphism, Files, Graphics, Strings, Sorting and Searching Methods, Stack, Queues, Link-Lists, Trees and Mini-Projects.
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2013
(77)
-
▼
February
(20)
- C++ Program To Find Number Of Odd & Even Numbers.
- C Program To Find & Print An Armstrong Number.
- C Program To Find & Print A Strong Number.
- C Program To Find & Print A Perfect Number.
- Commenting Style In 'C' & 'C++'.
- Good Coding Practices.
- C Program To Print Pyramid Of Numbers.
- C++ Program To Display Object Details Using Access...
- C Program To Find & Print Twin Prime Numbers.
- C Program To Find Average Of Odd & Even Numbers Up...
- C Program To Print Even Numbers Upto A User-Specif...
- C Program To Print Odd Numbers Upto A User-Specifi...
- C Program For Printing A Floyd's Triangle.
- C Program To Print Multiplication Tables.
- C Program For Printing Fibonacci Series.
- C++ Program For Defining A Class [Class Definition...
- C Program To Print Prime Numbers Upto A User-Speci...
- C Program To Find A Prime Number.
- C++ Program To Print Prime Numbers Upto A User-Spe...
- C Program To Find Odd Or Even Number.
-
▼
February
(20)
No comments:
Post a Comment