Problem Description
The college ground is rectangular in shape. The Management decides to build a fence around the ground. In order to help the construction workers to build a straight fence, they planned to place a thick rope around the ground. They wanted to buy only the exact length of the rope that is needed. They also wanted to cover the entire ground with a thick carpet during rainy season. They wanted to buy only the exact quantity of carpet that is needed. They requested your help.
Can you please help them by writing a C program to find the exact length of the rope and the exact quantity of carper that is required?
Input Format:
Input consists of 2 integers. The first integer corresponds to the length of the ground and the second integer corresponds to the breadth of the ground.Test Case 1
Input (stdin)50 20
Expected OutputRequired length is 140 m Required quantity of carpet is 1000 sqm
Test Case 2
Input (stdin)121 23
Expected OutputRequired length is 288 m Required quantity of carpet is 2783 sqmProgram
#include <stdio.h> int main() { int l,b; scanf("%d%d",&l,&b); printf("Required length is %d m\n",2*l+2*b); printf("Required quantity of carpet is %d sqm\n",l*b); return 0; }
No comments:
Post a Comment
Note: only a member of this blog may post a comment.