Variable is Being used without initialized

help me on this code .. it said my width1 is being used wihtout being initialized.. what does it mean?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
using namespace std;

double Area(double height, double width);
double Perimeter(double height, double width, double height1, double width1);

int main()
{
	cout<<"Enter height of rectangle :";
	double height,height1;
	cin>>height;
	cout<<"Enter width of rectangle :";
	double width,width1;
	cin>>width;
	cout<<"Area of rectangle is :"<<Area(height,width)<<endl;
	cout<<"Perimeter of rectangle is :"<<Perimeter(height,width,height1,width1)<<endl;

	return 0;
}

double Area(double height, double width)
{
	return height*width;
}

double Perimeter(double height, double width, double height1, double width1)
{
	height=height1;
	width=width1;
	return height+width+height1+width1;
}
Quiz: if you run your program and entered 14 when asked for height, 18 when asked for width, wtaht will width1 and height1 on line 17 Perimeter call equals to?
User inputs height, user inputs width... do you really need any more variables than that?

Area
(height*width)

and

Perimeter
2 * (height+width)

it said my width1 is being used without being initialized.. what does it mean?


Means width1 does not have an initial value (or has never received one either before it is called). I am new myself to c++ but you seem to have overcomplicated this. I wont post a solution straight away though because that has never helped me, and I don't think it will help you either.

Post back though if you're really struggling :)
Topic archived. No new replies allowed.