Wednesday 9 March 2016

FENCING THE GROUND


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 needed?

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.

Output Format:

Refer Sample Input and Output for exact formatting specifications.

Sample Input and Output:
[All text in bold corresponds to input and the rest corresponds to output]
Enter the length of the ground
50
Enter the width of the ground
20
The length of the rope needed is 140m
The quantity of carpet needed is 1000sqm

Code:
  #include<stdio.h>
int main(){
  int l,w;
  printf("Enter the length of the ground\n");
  scanf("%d",&l);
  printf("Enter the width of the ground\n");
  scanf("%d",&w);
  printf("The length of the rope needed is %dm",(2*l)+(2*w));
  printf("\nThe quantity of carpet needed is %dsqm",l*w);
  return 0;
}

8 comments:

  1. what would be the JAVA program of the same logic

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. how to print the values with its units in java?

    ReplyDelete
  4. This makes it appear that the pro-ambulance supporters were right. So, more and more is ultimately spent on the fleet of vehicles to deal with the physical and emotional disasters which ensue year after year, chain link fence privacy

    ReplyDelete
  5. Damaged fence? Do not worry..!!

    Bramalea Fence Ltd. provides complete Fence Repair Mississauga that have been damaged by weather, accidents and age.

    ReplyDelete
  6. a=int(input("Enter the lenght of the ground:")
    b=int(input("Enter the width of the ground:")
    print("The lenght of rope needed is",2*a+2*b,"m")
    print("The quantity of carpet needed is",a*b,"sqm")

    ReplyDelete