Custom Search

Friday 25 November 2011

Q3)Write a program to check wheather the given number is amstrong or not


Author: Sanif S S 
Site: theeduzone.blogspot.com 
Email: sanifss@gmail.com

#include<stdio.h>
#include<conio.h>
void main()
{
 clrscr();
 int n,c,t,s=0;
 printf("enter a number\n");
 scanf("%d",&n);
 t=n;
 while(n>0)
 {
  c=n%10;
  s=s+(c*c*c);
  n=n/10;
 }
 if(s==t)
 {
  printf("the number is armstrong");
 }
 else
 {
  printf("the number is not armstrong");
 }
 getch();
}

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...