This program is working fine. No bugs. Sanju :)
On Mon, Aug 29, 2011 at 11:06 PM, Mohit Gupta <[email protected]>wrote: > *1.* > /* Print armstrong numbers from 1 to 500 */ > /*1st version of prgrm: I am using pow function*/ > #include<stdio.h> > #include<conio.h> > #include<math.h> > int main() > { > int num=1,temp,sum,r; > while(num<=500){ > sum=0; > temp=num; > while(temp){ > r=temp%10; > sum+=pow(r,3); > temp/=10; > } > if(sum==num) > printf("%d\n",num); > num++; > } > getch(); > return 0; > } > > It prints : > 1 > 370 > 371 > 407 > > But it does not print 153 which is also armstrong number. WHY??? > > BUT if I change: pow(r,3) to r*r*r in code....then it prints: > 1 > 153 > 370 > 371 > 407 > > WHY 153 was not printed if i use pow() function??? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
