Advertisement
tonygms3

Question 8 Assignment

Dec 23rd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main(){
  4.     int num,r,sum,temp;
  5.  
  6.     for(num=1;num<=500;num++){
  7.          temp=num;
  8.          sum = 0;
  9.  
  10.          while(temp!=0){
  11.              r=temp%10;
  12.              temp=temp/10;
  13.              sum=sum+(pow(r,3));
  14.          }
  15.          if(sum==num)
  16.              printf("%d\n",num);
  17.     }
  18.  
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement