Hey I am new to c++, I am trying to work with programmer defined functions,

I was wondering if someone could tell me where I went wrong with this:

#include "stdafx.h"
#include <iostream>
using namespace std;

double hatsize(double user_weight, double user_height); // hat size function declaration

int _tmain(int argc, _TCHAR* argv[])
	const double user_height;
	const double user_weight;
	const int user_age;
	//char ans; // answer for do while loop. *repeat the program

	double hat; // hat size result

	// User details entry
	cout << "Computing Clothing Sizes\n";
	cout << "________________________\n";
	cout << "Please enter your height in inches:\n";
	cin >> user_height;
	cout << "Please enter your weight in pounds:\n";
	cin >> user_weight;
	cout << "\n";
	cout << "Please enter your age:\n";
	cin >> user_age;
	cout << endl;

	hat = hatsize(user_weight, user_height); // hat size function call
	cout << "Your hat size is: ";
	cout << hat;

	return 0;

	//Hat size Formula     weight in pounds divided by height in inches and all that multiplied by 2.9
	double hatsize(double user_weight, double user_height)  // hatsize function heading
	return (user_weight / user_height * 2.9);

I am basically trying to get this code (not yet complete) in to functions for each piece of clothing.

Thank you for your time :icon_cool:

Votes + Comments
Thanks for using code tags
10 Years
Discussion Span
Last Post by Ancient Dragon

the const keyword tells the compiler that the variable will never ever be changed. Since you expect to enter value for user_height then it cannot be declared const. Same with the other variables.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.