:

# What am I doing wrong?

Added by: ~Andreawws!, 2011 V 04

Added by: ~Andreawws!, 2011 V 04

Ok some info I have too compile a program that solves this:
1 coin on square on, 2 on 2, 4 on 3 and so on how many are there on square n

Now I managed too get it too compile using int, long int double int and so on, but ALL of them overload if I choose a value greater than 31 for n.

Now I see no problems with my source code, tho it gives eleven errors when using the ttmath::UInt, so I switched back.

#include "stdafx.h"
#include <iostream>
#include <process.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <ttmath/ttmath.h>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
long long int num=2,num1, res;
m:
cout<<"/////////////////////////////////"< <endl;
cout<<"//Enter a number for variable n//"<<endl;
cout<<"/////////////////////////////////"< <endl;
cin>>num1;
if(num1==0.0)
{cout<<"Sorry, please enter a value which is not zero"<<endl;
goto m;}
else {res=pow(num,num1-1.0);
}
{system ("pause");
return 0;}
}

Can anyone tell me what the solution for my problem is? How do I use it properly?

Some info:
I am using Visual c++ 2008 express.
I am an intermediate programmer.
And I have no clue what I am doing wrong.
The equation is 2^n-1=X.

//Andreawws!

Added by: tomek, 2011 V 04

You should have shown us the wrong program. This one is properly compiled on MSVC 2008.

#include <iostream>
#include "ttmath/ttmath.h"

using namespace std;

int main()
{
ttmath::Int<10> num=2, num1=-1, res;

do
{
if( num1 == 0 )
cout << "Sorry, please enter a value which is not zero" << endl;

cout << "/////////////////////////////////" <<endl;
cout << "//Enter a number for variable n//" <<endl;
cout << "/////////////////////////////////" <<endl;

cin >> num1;
}
while( num1 == 0 );

// original one was: res = pow(num,num1-1.0);
// with ttmath it can be:
res = num;
int carry = res.Pow(num1 - 1);

if( carry )
cout << "too large value" << endl;
else
}

Added by: ~Andreawws!, 2011 V 07

Oh I see, now I know what I did wrong, and I posted the working code.
thanks ^^

Added by: ~Andreawws!, 2011 V 07

except it gave me 28 errors and 2 warnings -_-

Added by: tomek, 2011 V 16

Show the errors pls.

Added by: ~Andeawws!, 2011 V 25

Sorry for taking so long to respond, I had some issues with my computer, I am now on a linux system (Ubuntu)

so I can't give the errors, would this code compile under linux?

Added by: ~Andreawws!, 2011 VI 05

bump.