URI online judge 1002 solution: Area of a Circle

URI online judge 1002 solution: Area of a Circle

URI 1002 Problem: Program to Print Area of a Circle

URI 1002 Problem solution: In this problem, you have to write a program that takes the radius as input and print Area of a Circle as output.

Read also>

According to URI Online judge, problem 1002 is given below:
The formula to calculate the area of a circumference is defined as A = π . R2. Considering to this problem that π = 3.14159:

Calculate the area using the formula given in the problem description.

Input

The input contains a value of floating point (double precision), that is the variable R.

Output

Present the message “A=” followed by the value of the variable, as in the example bellow, with four places after the decimal point. Use all double precision variables. Like all the problems, don’t forget to print the end of line after the result, otherwise you will receive “Presentation Error”.

Input SampleOutput Sample
2.00A=12.5664
100.64A=31819.3103
50.00A=70685.7750

URI 1002 Solution in C: Area of a Circle

Program:

#include<stdio.h>
int main()
#define n 3.14159
{
    double R,A;
    scanf("%lf", &R);
    A = n * R * R;
    printf("A=%.4lf\n", A);
    return 0;
}

Or

#include<stdio.h>
int main()
{
    double R,A;
    scanf("%lf", &R);
    A = 3.14159 * R * R;
    printf("A=%.4lf\n", A);
    return 0;
}
URI 1002 Accepted in C

Test Input:

This is a test input in C: 2.00

Test Output:

This is the output of test input: A=12.5664

URI online judge 1002 Input and Output in C

To run this code (URI 1002 Solution/Answer) on your Laptop or PC, download Code::blocks, and to run in your android mobile download CppDroid – C/C++ IDE from play store or you can simply search on google Online C Compiler or Online C++ Compiler, you’ll get plenty of online compilers! Try them!

Was this article really helpful?
YesNo

LEAVE A REPLY

Please enter your comment!
Please enter your name here