Karl loves to play with shapes and his sister is interested in Mathematics. They got a wooden box which is square in shape with length x cm and a round bangle with radius r cm and decided to play with it. They started playing and his sister asked him to find whether the circle will fit into the square. Help Karl to find whether the circle will fit into a square or not. If the circle fits, display “circle can be inside a square” else display “circle cannot be inside a square”.
INPUT FORMAT:
Input consist of 2 integers.
First input corresponds to the radius of a circle.
Second input corresponds to the length of a square.
SAMPLE INPUT:
77
65
SAMPLE OUTPUT:
circle cannot be inside a square
Answers
PROGRAM
I have written a user defined C++ program for your above question. Kindly have a look over it.
#include<iostream.h>
#include<conio.h>
#include<process.h>
void main()
{
clrscr();
int r, s;
char ch;
A:
cout<<"Enter the radius of the bangle \n";
cin>>r;
cout<<"Enter the length size of square wooden box \n";
cin>>s;
if(s>= 2*r)
{
cout<<"Circle can be inside the square. \n";
}
else
{
cout<<"Circle cannot be inside the square. \n";
}
cout<<"Want to repeat (y/n)? \n";
cin>>ch;
if(ch=='y')
{
goto A;
}
else if(ch=='n')
{
exit(0);
}
getch();
}
Related Questions :-
https://brainly.in/question/16088863
https://brainly.in/question/6172559
https://brainly.in/question/11831616
https://brainly.in/question/14658113
https://brainly.in/question/14581229
https://brainly.in/question/6172600
https://brainly.in/question/13084271
Answer:
#include<iostream>
using namespace std;
int main()
{
int rad,s,ac,as,d;
cin>>rad>>s;
as=s*s;
d=2*rad;
ac=(22/7)*rad*rad;
if(ac<as && d<=s)
cout<<"circle can be inside a square";
else
cout<<"circle cannot be inside a square";
}