Armstrong Number - C Programming

Posted on:
tags: , , ,
Armstrong Number
19/10/2011



#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.




if you have any query regarding the program then free to ask at youthtalentauzzar@gmail.com


No comments:

Post a Comment

< >