Sunday 8 April 2012

12).Check Whether a Given Number is Armstrong .

#include<conio.h>
#include<iostream.h>
void main()
{
 clrscr();
  int N,temp,sum=0,remainder;
  cout<<"Enter the Number ";
  cin>>N;
  temp=N;
  while(temp!=0)
  {
   remainder=temp%10;
   sum=sum+remainder*remainder*remainder;
   temp=temp/10;

  }
  if(N==sum)
   {
    cout<<"The Number is Armstrong";
   }
   else
   cout<<"The Number is not Armstrong";



       getch();

}

No comments:

Post a Comment

Write a program which reads a set of integers into an integer array and then prints "YES"if all of them are same otherwise print "NO".

#include<stdio.h> int main() { int a[10],M=0,i,n; printf("enter a value for n\n"); scanf("%d",&n); fo...