0
Hi, I want to create a function in CS that tests a number. If it is positive, the function calculate its square (x²)but if.....
.....it is negative, the function calculate its cubic (x³) and then I want to call up the function for the number 3. How can I do that?
5 Respuestas
+ 1
private double Func(double n)
{
return Math.Pow(n, n>=0?2:3);
}
0
well. well. the obvious answer. did you tried attempting that before you could answer here? if i have to do it. I would first check the number using if statement.
0
Yes
0
did you get stuck somewhere while you were doing the assignment?
0
Thanks