Program To Check Whether a Number is a Armstrong or not.

#include<iostream>
using namespace std;
int main()
{
int n,n1,rem,num=0;
cout<<"Enter a positive number:";
cin>>n;
n1=n;
while (n1!=0){
rem=n1%10;
num+=rem*rem*rem;
n1=n1/10;
}
if(num==n)
cout<<"The number is armstrong\n\n";
else
cout<<"The number is not a armstrong\n\n";
cout<<"/*\nName-Sanjampreet Singh\nRoll Number-1507967\n*/";
}

Output:

Comments

Popular posts from this blog

To implement the various components of HTML5 Canvas

Program to illustrate the concept of templates.

Program to illustrate the order of execution of constructors and destructors in inheritance.