DO NOT MISS

Ads

Sunday, 31 July 2016

Program 18 Using While Loop



The sum of the digits of the qubes is equal to the given number is known as a Armstrong number.


Example:- (153,371,407)


#include<stdio.h> 
#include<conio.h> 

void main() 

      { 

           int n,sum=0,r,t=0; 
           clrscr(); 

           printf("enter a number:"); 
           scanf("%d",&n); 

           t=n; 
           while(n!=0) 
                 { 
                      r=n%10; 
                      sum=sum+r*r*r; 
                      n=n/10; 
                 } 


           if(sum==t) 
           printf("the no is armstrang"); 
           else 
           printf("the no is not armstrang"); 

           getch(); 

      }


Output:-



Explanation:
______________________________________________________
______________________________________________________
______________________________________________________
_____________________________________________________



Greataims

 
Copyright © 2016 Computersadda. Designed by @ Computersadda Team - Published By Greataims