Monday, April 29, 2019

Pool

  • Problem Description

    You are planning to go for swimming classes. You would prefer to enroll in the center which has the swimming pool of a greater area. In the first centre that you visit, the swimming pool is a circular shape(radius-r). In the next centre that you visit, the swimming pool is of a square shape (side-S). Write a program that will help you to make the choice of the swimming pool. 

    Input : 
    Input consists of 2 integers. The first integer correspond to the radius (r) of the circular swimming pool, The second integer corresponds to the side (S) of the square swimming pool. 
  • Test Case 1

    Input (stdin)
    4 4

    Expected Output
    I prefer centre 1
  • Test Case 2

    Input (stdin)
    4 8

    Expected Output
    I prefer centre 2
Solution
#include <stdio.h>
const double pi=3.141;
int main ()
{
int r,s;
scanf ("%d%d",&r,&s);
if ((pi*r*r)>(s*s))
{
printf ("I prefer centre 1");
}
else
{
printf ("I prefer centre 2");
}
return 0;
}


No comments:

Post a Comment

Parity

Problem Description Ram and Sita playing the parity game. Two types of parity are there. One is odd parity and next is even parity. Ram will...