+ 10

# Area of a circle c# challenge solution

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { const double pi = 3.14; double radius; radius = Convert.ToDouble(Console.ReadLine()); double area = pi * (radius * radius); Console.WriteLine(area); //your code goes here } } }

11 Answers

+ 2

Is it also possible to write the code with ()² or ^2?
I already know the writing goes like ... (radius * radius) but i am wondering if there is a more easy way of coding it ...
Thx ;)

+ 3

cameron Thanks!

+ 1

Yeah theres definitely more ways, this is just a simple plain version for understanding. Possibly, but the ^ operator is not able to be applied to double and int operands normally.

+ 1

YourMinecraftGuy is there a specific part you dont understand? If you really dont understand any of it at all, id suggest startimg the course/program from the start and really reading the information, it really explains in the best possible way you will find online. And perhaps google for short begginner tutorials im order to see how and why certain things get done and placed. Just say if you need more help

+ 1

also can use var area = pi*radius*radius. I also got a correct answer.

+ 1

Why is it radius * radius? That makes no sense to me. You only need to multiply radius and pi together

0

I guess you should use Math.PI constant to avoid floating point precision error by using only Pi with two decimals (or even any other different Pi value)...

0

I don´t understand anything...

0

Hello I having trouble with the area of the circle project. how do I get all 5 case test at once I already solved all five by one at a time and also by displaying them all at once any tips to help.

0

Thr exact code attached in this post solves for all cases at once

0

other solution
using System;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
double pi = 3.14;
double radius;
radius = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(pi * (radius*radius));
}
}
}