C++ Program to check the input number is Armstrong number or not.
Armstrong number c++ program: A number is armstrong if the sum of cubes of
individual digits of a number is equal to the number itself. For example
371 is an armstrong number as 33 + 73 + 13 = 371. Some other armstrong numbers are: 0, 1, 153, 370, 407.
Source Code:-
#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
int temp,num,sum=0,r;
cout<<"Program to check Armstrong condition by-Tarun Rawat\n\n";
cout<<"Enter a number : ";
cin>>num;
temp=num;
while(num!=0)
{r=num%10;
num=num/10;
sum=sum+(r*r*r);
}
if(sum==temp)
cout<<endl<<temp<<" is a Armstrong number. \n";
else cout<<endl<<temp<<" is not a Armstrong number./n";
getch();
}
Welcome to " way2cplusplus.blogspot.in " Objective of this blog is to implement various Computer Science Engineering Lab problems into C++ programming language. These are basically most common Lab Exercise problems based on the curriculum of engineering colleges throughout the Nation. These lab exercises are also relevant to Data structure. Simply C++ programming zone...
nice :)
ReplyDeleteyeah it works thx
ReplyDeletethasnks a lot sir
ReplyDelete