pow syntax errors help!! due today!!

this is the equation i have and i know it's wrong but i dont know how to fix it
this is my first time learning to program so i dont really know what im doing.


lucky = static_cast <int>((100 * m pow (m, 2) + 10*d) pow (d, 3) / y + sqrt(w pow (w, 6)/h) % 10 + 1

the errors are

error C2146: syntax error : missing ')' before identifier 'pow'
error C2059: syntax error : ')'

the whole code is


#include <iostream>

#include <cmath>

using namespace std;

int main()

{

//Declare double constants CM_PER_INCH = 2.54 and LB_PER_KG = 2.2046

const double LB_PER_KG = 2.2046;

const double CM_PER_INCH = 2.54;

//Declare integer variables m, d, y, lucky

int m, d, y, lucky;

//Declare double variables h, w

double h, w;

// Display "My Lucky Number Calculator"

cout << "My Lucky Number Calculator ";

// Display prompt for birthdate month

cout << "What is your birthdate month? ";

// Read integer into m

cin >> m;

// Display prompt for birthdate day

cout << "What is your birthdate day? ";

// Read integer into d

cin >> d;

// Display prompt for birthdate year in YYYY format

cout << "What is your birthdate year in YYYY format? ";

// Read integer into y

cin >> y;

// Display prompt for height in inches

cout << "What is your height in inches? ";

// Read integer into h

cin >> h;

// Display prompt for weight in pounds

cout << "What is your weight in pounds? ";

// Read integer into w

cin >> w;

// Convert height in inches into centimeters: h = h * 2.54

//Use the constant declared

h = h * CM_PER_INCH;

// Convert weight in pounds into kilograms: w = w / 2.20462262

//Use the constant declared

w = w / LB_PER_KG;

// Calculate lucky number as

//lucky = Int((100*m^2 + 10*d^3) / y + sqrt(w^6/h)) mod 10 + 1

//use pow() function

//use sqrt() function

//use static_cast<int>

//% is the operator for mod

lucky = static_cast <int>((100*m pow (m, 2) + 10*d pow (d, 3) / y + sqrt(w pow (w, 6)/h) % 10 + 1

// Display "Your lucky number is " lucky ". Thank you, that will be $25."

cout << "Your lucky number is " lucky " . Thank you, that will be $25.";

return 0;

}
Last edited on
Well: lucky = static_cast <int>((100*m pow (m, 2) + 10*d pow (d, 3) / y + sqrt(w pow (w, 6)/h) % 10 + 1 -> lucky = static_cast <int>((100*pow (m, 2) + 10*pow (d, 3) / y + sqrt(pow (w, 6)/h) % 10 + 1
"pow" is a function, not an operator. You can't omit the '*' in C++ if you want to multiply something either.
Please use code tags when you post code. I can barely read that.
static_cast <int>
static_cast <int>
whats this for?
whats the topic to learn it
static_cast <int> someone in class told me to that in there and the book says its a common type cast expression.

i put in coder777's

lucky = static_cast <int>((100*pow (m, 2) + 10*pow (d, 3) / y + sqrt(pow (w, 6)/h) % 10 + 1

and the errors are

'%' : illegal, left operand has type 'double'
syntax error : missing ')' before identifier 'cout'
syntax error : missing '(' before identifier 'cout'
syntax error : missing ')' before '}'
syntax error : missing ';' before ')'
you need to add the necessary parenthesis and a semicolon at the end of the line.
Topic archived. No new replies allowed.