Here is my code:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int x;
int y = pow(2, x);
cin>>x;
cout<< y;
system("pause");
return 0;
}
Why do I get a compile error? LNK1561 entry point must be defined
I am using Visual Studio Express.
You need to assign a value to x before it is used
int x;
int y = pow(2, x); // <--- what is the value of x here?
Try getting the value of x
from the input first.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int x;
cin >> x;
int y = pow(2, x);
cout<< y;
system("pause");
return 0;
}
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int x;
//int y = pow(2, x);//(1)
//cin>>x;//(2)
//exchange the lines (2) and (1)
cin>>x;//(2)
int y = pow(2, x);//(1)
cout<< y;
system("pause");
return 0;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.