Saturday, August 18, 2018

FENCING THE GROUND


  • 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.
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      int l,b;
      scanf("%d%d",&l,&b);
      printf("Required length is %dm\n",2*l+2*b);
      printf("Required quantity of carpet is %dsqm\n",l*b);
      return 0;
    }Test Case 1

  • Input (stdin)
    50 20
    
    
    Expected Output
    Required length is 140m
    
    Required quantity of carpet is 1000sqm
  • Test Case 2

    Input (stdin)
    121 23
    
    
    Expected Output
    Required length is 288m
    
    Required quantity of carpet is 2783sqm

No comments:

Post a Comment