HACKERS UNDERGROUND © 2012 BY RISHABH SHARMA

Friday, 13 January 2012

Armstrong Number

#include<stdio.h>
#include<conio.h>
void main(){
 int a,t,y,q;// taking variables.
 clrscr();//to clear the screen  .
 printf("\t\t\t***This is Armstrong Program***\n\n\n\n");
 printf("\tEnter a dirsire number:");
 scanf("%d",&a); //taking the number as input.
 t=0;
 t=a;//now the value of variable t and a are same.
 q=0; y=0;
 while(a>0){   //from here the main work start for calculating the armstrong number.
  y=a%10;
  q=q+(y*y*y);
  a=a/10;
  }end of the loop.
 if(t==q)  //comparing the value of the variables t and q
 printf("\n\nYupp !! This is a ARMSTRONG NUMBERR :)");
 else
 printf("\n\nSoRRy!! This is not a ARMSTRONG NUMBER :(");
getch();
}//end of the program.

post by rishabh sharma hackersunderground

0 comments:

Post a Comment

 
Design by HACKERS UNDERGROUND
HACKERS UNDERGROUND © 2012 BY RISHABH SHARMA