eorror on the top (preprocessor line i think)

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;

}
Last edited on
Why not?
double weight = 1685E-2;?

Also,
cout <<"and my weight is" << weight << "pounds." << endl;
this is first time i'am coding and i dont feel comfartable with the whole code, but i only got error on the preprocessor line after running it.
Last edited on
Can you post the compiler error logs here?
closed account (48T7M4Gy)
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>

using namespace 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)
Last edited on
Topic archived. No new replies allowed.