hi,
i've been trying to run this simple code, but i got errors on the preprocessor directive. Not sure why. The instruction is as follows with the source code.
"My age is 26 and my weight is 168.5 pounds?"
#include <iostream>
#include <cstdlib>
using namespace std;
int main ()
{
float age = 16;
double weight = 1685E-1;
cout <<" My age is " << age <<endl;
cout <<"and my weight is" << weight << "pounds."endl;
return 0;
#include <iostream>
usingnamespace std;
int main ()
{
float age = 16;
double weight = 1685E-1; // or 168.5 is the normal way, both are correct though
cout << "My age is " << age << " and my weight is " << weight << " pounds." << endl; // <--
return 0;
}
You were nearly there with just a few small changes. You can put the output on two lines if you like of course.
My age is 16 and my weight is 168.5 pounds.
Exit code: 0 (normal program termination)