im writing a code where im multiplying 2 and 3 with their powers, ie (2 ^ i) * ( 3 ^ j )..n if the resultant sum is greater than 32 bits then im not storin that value in my array n so i check with the next powers ie if for some i n j the ans is less than the previous 1(since a value greater than 64bits gets truncated n the remainin number left after truncatin is less than the prev num) then im breaking n startin with the next i value...also while checkin if the answer is more than 64 bits i store it in the array only if isnt more than 64 bits..

the array should hold values like 0,1,2,3,4,6,8,9,12,18 etc n my code is not printing the values of 2 powers..

this is my code:

i know its not very neat n all but i still dont know why my break line doesnt go to my first for loop...can u please tell me the error..

thanks for reading!

the array should hold values like 0,1,2,3,4,6,8,9,12,18 etc n my code is not printing the values of 2 powers..

this is my code:

Code:

#include<iostream> #include<math.h> using namespace std; main() { int c,n,d; d=c=pow(32,2); unsigned long a[d],b[c],t; d=c=0; a[d]=0; b[c]=0; for(int i=0;i<32;i++) { for(int j=0;j<32;j++) { b[c]=pow(2,i)*pow(3,j); if(b[c]>b[c-1]) { a[++d]=b[c++]; cout<<a[d]<<" "; } else { c--; break; } } } }

thanks for reading!

*Last edited by shabbir; 21May2009 at 10:00.. Reason: Code blocks*