0

C# code error

I have the following piece of code: 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()); Console.WriteLine(pi*(radius**2)); } } } When I run it, it shows up error CS0193 for line 16 (the Console.WriteLine...). It says that 'the * or -> operator must be applied to a pointer'. Two questions: what exactly IS a pointer, and why does this error show up (and how do I solve it?). Thanks in advance

10th Oct 2021, 6:35 PM
Kamil Hamid
Kamil Hamid - avatar
7 Answers
+ 2
So is ** not a viable operator in C#?
10th Oct 2021, 6:50 PM
Kamil Hamid
Kamil Hamid - avatar
+ 1
Try it this way: Console.WriteLine(pi*(radius*radius));
10th Oct 2021, 6:44 PM
Coding Cat
Coding Cat - avatar
+ 1
Or, you have to use Math.Pow() like this "Math.Pow(radius, 2)"
10th Oct 2021, 6:49 PM
Coding Cat
Coding Cat - avatar
+ 1
Thank you!
10th Oct 2021, 6:52 PM
Kamil Hamid
Kamil Hamid - avatar
0
Thank you, it worked! Is it possible for me to know why that error occurs?
10th Oct 2021, 6:48 PM
Kamil Hamid
Kamil Hamid - avatar
0
That's because you can't square a number with **
10th Oct 2021, 6:51 PM
Coding Cat
Coding Cat - avatar