[Fixed, dont worry]

Hello, this is my first post on the forums so sorry if it’s a little iffy. I’m very new to C++ and was confused by an error I got while coding. While doing the lesson, it offered me to do an optional review where the user inputs an object weight and the code calculates the object’s weight on mars. This is the code I made:


int main() {

// Add your code below

double weightE = 0;

double weightM = 0;

std::cout << "Insert object weight here: ";

std::cin >> weightE;

weightM = weightE * 0.38;

std:: cout << "Object weight on Mars: " << weightM << “\n”;


Whenever I tried to compile it, this error message popped up:
review.cpp: In function ‘int main()’:
review.cpp:9:1: error: expected ‘;’ before ‘std’
std::cin >> weightE;
review.cpp:14:1: error: expected ‘;’ before ‘}’ token
I’m not sure how to fix it and there aren’t any hints available. Can someone please help? Thanks.

Hey there!

Sorry you’re having trouble. The post may be a little easier for other learners to read and respond to if you format the code within. To learn how, you can check out this guide in our Getting Started category.

For a little more information on how best to format your questions to get helpful answers, check out this How-to.