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:

Ancient Dragon commented: Thanks for using code tags +21

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.