Area and Perimeter

I need help with something, I'm new to programming, currently doing an assignment that calculates the Area and perimeter of a Rectangle. I don't know what I'm doing wrong.


#include <stdio.h>
int main()

{
float Area; //used to calculate the Area of a rectangle
float Perimeter; //used to calculate the Perimeter of a rectangle
float length; //length of rectangle
float width; //width of rectangle
length = 3.5; //length of rectangle
width = 5.48; //width of rectangle
Area = length*width;
Perimeter = 2(length+width);
printf("\nArea of rectangle: %fArea Square units");
printf("\nPerimeter of rectangle: %fPerimeter units");

return 0;
}



I have to have it in this format or hypergrade will fail me

Program Output
Area of rectangle: 19.180000 square units
Perimeter of rectangle: 17.959999 units

Last edited on
I believe it is:

1
2
printf("\nArea of rectangle: %f Square units" , Area);
printf("\nPerimeter of rectangle: %f units" , Perimeter);
#include <stdio.h>
int main()

{
float Area; //used to calculate the Area of a rectangle
float Perimeter; //used to calculate the Perimeter of a rectangle
float length; //length of rectangle
float width; //width of rectangle
length = 3.5; //length of rectangle
width = 5.48; //width of rectangle
Area = length*width;
Perimeter = 2(length+width);
printf("\nArea of rectangle: %fArea Square units", Area);
printf("\nPerimeter of rectangle: %fPerimeter units", Perimeter);

return 0;
}

Now I'm having problems with the Perimeter formula.
"19 28 [Error] expression cannot be used as a function"

The compiler will see the Perimeter formula as a function, just put a * inbetween the 2 and the brackets so it knows its an equation.

Perimeter = 2*(length+width);

Hope this helps
Thank you so much guys! My first time on this site. So glad I found it. I got a 100! Thanks again! You guys are great!
Topic archived. No new replies allowed.