Reputation: 3863
I wrote a simple c++ program to calculate quadratic equations. I compiled it on ubuntu linux with g++.
Here is the code by the way:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double a,b,c;
double x,x2;
cout<<"Give a: ";
cin>>a;
cout<<"Give b: ";
cin>>b;
cout <<"Give c: ";
cin>>c;
if (a==0)
{
if (b==0)
{
if (c==0)
{
cout<<"Solution indeterminable";
return 0;
}
else
{
cout<<"No solution";
return 0;
}
}
else
{
x=-c/b;
cout<<"The only root is x: "<<x;
return 0;
}
}
else
{
double b_sqr=b*b;
if (b_sqr>4*b*c)
{
cout<<"Complex roots: ";
return 0;
}
else if (b_sqr==4*b*c)
{
x=-b/(2*a);
cout<<"The only solution is x: "<<x;
return 0;
}
else
{
x=-b+(sqrt((b*b)-(4*a*c)))/(2*2);
x2=-b-(sqrt((b*b)-(4*a*c)))/(2*2);
cout<<"The first root is x1: "<<x;
cout<<"The first root is x2: "<<x2;
return 0;
}
}
}
Now when i tried to run this on my x64 Windows 7, this is what i got:
Unsupported 16 bit application:
The program or feature equation.exe cannot start or run due to incompatibility with 64-bit versions of windows. Please contact the software vendor to ask if a 64-bit Windows compatible version is available
Well i am the author and i wrote simpe c++ to code it. Whats up with this compatibility thing?
How can i manage to run it in windows 7 x64? Thanks!
Upvotes: 0
Views: 2658
Reputation: 352
I had the same problem with MinGW when I compiled files with extension .h; if I change the extension of the source file to .cpp before compilation, the executable is compatible with my 64-bit windows 7. The reason? No idea. I'm a newby.
Upvotes: 0
Reputation: 613531
Windows cannot run executables that target other operating systems. You need to recompile with a compiler that targets Windows. For instance mingw is probably the most widely used GCC port for Windows.
Upvotes: 3