Rectangle
Completed
Read the width and height of a rectangle (integers) and print the area and perimeter.
Input
Two integers.
Output
area=A perimeter=P
Example
Input
3 4
Output
area=12 perimeter=14
Editor
C
Hints
Area is w * h, perimeter is 2 * (w + h).
Solution explanation
Expressions can be calculated directly inside the printf arguments.
Show solution
#include <stdio.h>
int main() {
int w, h;
scanf("%d %d", &w, &h);
printf("area=%d perimeter=%d\n", w * h, 2 * (w + h));
return 0;
}