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;
cout<<"/////////////////////////////////"< <endl;
cout<<"//Enter a number for variable n//"<<endl;
cout<<"/////////////////////////////////"< <endl;
{cout<<"Sorry, please enter a value which is not zero"<<endl;
goto m;}
else {res=pow(num,num1-1.0);
cout<<" "<<res<<" is your answer, punk!"<<endl;
{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.

Thanks in advance

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;

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;
cout << res << " is your answer, punk!" << endl;

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

I need an answer. plox

Added by: tomek, 2011 VI 05

TTmath works on x86 and amd64 platforms and probably on other little endian platforms too. The operating system doesn't matter. And currently only two compilers are supported: GCC and Microsoft Visual C++.