Write a float function rectangle() that computes and returns the area of a rectangle using its two float formal parameters h and w, where h is the height and w is the width of the rectangle

Recommended Answers

Are you talking about this?
Well show some code next time. We are here to help not to do your homework.

float recSq(float x, float y){
   return x*y;
   }
Jump to Post

All 3 Replies

maybe something like this?

float rectangle() {
  float h=5;
  float w=5;
  float areaOfRec;
  areaOfRec = h*w;
  return areaOfRec;
}

Are you talking about this?
Well show some code next time. We are here to help not to do your homework.

float recSq(float x, float y){
   return x*y;
   }

Pass hight and width to that function. rectangle(9.3,4.2);

float rectangle(float h, float w)
{
float ans;
ans=h*w;
return ans;
}
commented: You are not only giving the user the answer; you're also posting a less efficient method to the most above. -2
Be a part of the DaniWeb community

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