Pie Are Squared

Given the radius of a circle, calculate and print its area. The area of a circle can be computed usi…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

#include<stdio.h>
#define PI 3.1416
#define Area PI*r*r
int main()
{
    float r;
    scanf("%f",&r);

    printf("%.5f",Area);


    return 0;
}

whats the problem here??

@mik007 Please try to use a bit more accurate value for PI. You can use a value that has a few more decimal places.

take a more accurate value of pi like 15+ digits and print line will be printf(“%.10f”,Area);

1 Like
#include<stdio.h>
#define PI 3.141592653589793
int main()
{
    int r;
    double A;
    scanf("%d",&r);
    A=PI*r*r;
    printf("%f10",A);
    return 0;
}

PI = 3.1416
r = float(input())

print(PI * r * r)

getting wrong answer in test case 2 but why?

1 Like
import  math
r = input('enter a num:')
r = int(r)
area_num = float(math.pi * r**2)
print(area_num)

##this solution in python 3 .

@nafi0123 Remove the parameter from input():

r = input()

Why i’m getting wrong in Test Case 2

#include <stdio.h>
int main()
{
    float r,area,pi=3.1416;
    r<2000;
    scanf("%f",&r);
    area=pi*(r*r);
    printf("%f",area);
    return 0;
}
1 Like

Try using more accurate value of PI.

#include<stdio.h>
int main()
{
int a;
float pi,area;
pi=3.1415926536;
scanf("%d%lf",&a,&pi);
area=pi*a*a;
printf("%lf",area);
return 0 ;
}

Whats wrong?why it says wrong in test case 3?

@Samiya2004 You will have to use a more accurate value of pi.

Also, use double instead of float.

The problem statement has been updated. It now includes the value of pi that you can use to solve this problem.

I also try it.But there is no problem!!

#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;


int main()
{
    int  a;
    int  b;
    int c;
    c=acos(-1);
    b=-4;


    cin>>a;

    cout.setf(ios::fixed);
cout << setprecision(0) << a*b*c;


    return 0;
}

can u help me out?

@Saroboii What formula are you implementing here?

I am confused tbh … I am a beginner btw

import math

r=int(input(‘enter a num:’))

area_num=float(math.pi*(r**2))

print(area_num)
#what is the problem this code?

You have used:
r = int(input("enter a num:"))
Remove the enter a num parameter.
Use:
r = int(input())
And read the above discussions too. The same problem that you have faced has been responded to.

radius = float(input(“radius:”))
Pie = 3.1415926536

radius_square = radius**2

Area = Pie * radius_square

print(Area)

what’s wrong with this one?