I want to know how to make this simple formula work, whatever I do I always get 0 as if the formula is ignored. As seen below I want it so that if I type "area" it will automatically do the formula for me. I know that you can simply use
"cout << length*width << endl;"
but that's not what I'm trying to do here, I need to know how to make it automatically use a formula.
#include<iostream> // For cin, cout, and system
#include<string> // For string data type
#include<conio.h> // For getch function
#include<iomanip> // For fixed funciton
usingnamespace std; //So "std::cout" will be abbreviated to "cout"
int main()
{
//Variables
float length;
float width;
float area;
area = length*width;
//Asking for input
cout << "Enter the length and width." << endl;
cin >> length;
cin >> width;
//Output
cout << "Your area is: " << area << endl;
return 0;