Keep saying The variable 'width' is being used without being initialized.

#include <iostream>
#include <cmath>
using namespace std; 

int main() 
{ 
    float length;
    float width;
    float area; 

    cout << "Enter The Length Of The Rectangle: "; 
    cin >> length; 
    area=length*width; 

    cout <<"The area of the rectangle is : "<< area << endl;

    return 0; 
}

The error isn't unclear or ambiguous. width doesn't have a predictable value when you try to use it. You probably wanted another input request to fill it in just like length:

#include <iostream>
#include <cmath>

using namespace std; 

int main() 
{ 
    float length;
    float width;
    float area; 

    cout << "Enter The Length Of The Rectangle: "; 
    cin >> length; 

    cout << "Enter The Width Of The Rectangle: "; 
    cin >> width; 

    area = length * width; 

    cout <<"The area of the rectangle is : "<< area << endl;

    return 0; 
}

Also try this:

#include <iostream>
#include <cmath>

using namespace std;

void continue_()
{
    char c;
    cout << "Press any key to end program: ";
    cin >> c; 
    cout << endl;
}

int main()
{
    float area, length, width;

    cout << "What is your length? ";
    cin >> length;
    cout << endl;

    cout << "What is your width? ";
    cin >> width;
    cout << endl;

    cout << "Area = Length * Width" << endl << endl;

    area = (length * width);

    cout << "Your Area is: " area << endl << endl;

    continue_();
    return 0;
}

The admin posts above everyone else's states that we shouldn't use system("pause"), but that we should make up our own. So practice that also.

@ Zvjezdan Veselinovic

Can you explain the use of continue_() function ?

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.