Reputation: 37
My problem is that I need to write a complex mathematical equation which has me raise x
to the power of |y|
, both numbers entered by user. I've tried using the code below, but it produces a CS7036
error:
There is no argument given that corresponds to the required formal parameter 'y' of 'Math.Pow(double, double)'
class Program
{
static void Main(string[] args)
{
double x,y,z,v;
Console.Write("x=");
double.TryParse(Console.ReadLine(), out x);
Console.Write("y=");
double.TryParse(Console.ReadLine(), out y);
Console.Write("z=");
double.TryParse(Console.ReadLine(), out z);
v=(1+Math.Pow(Math.Sin(x+y)))/
Math.Abs(x-2*y/(1+x*x*y*y))*Math.Pow(x,Math.Abs(y))+
Math.Pow(Math.Cos(Math.Atan(1/z)),2);
Console.Write("v="+v);
Console.ReadKey();
}
}
Upvotes: 0
Views: 668
Reputation: 34957
(After the OP posted the code)
double x,y,z,v;
Console.Write("x=");
double.TryParse(Console.ReadLine(), out x);
Console.Write("y=");
double.TryParse(Console.ReadLine(), out y);
Console.Write("z=");
double.TryParse(Console.ReadLine(), out z);
v=(1+Math.Pow(Math.Sin(x+y)))/
Math.Abs(x-2*y/(1+x*x*y*y))*Math.Pow(x,Math.Abs(y))+
Math.Pow(Math.Cos(Math.Atan(1/z)),2);
Console.Write("v="+v);
Console.ReadKey();
Error CS7036 There is no argument given that corresponds to the required formal parameter 'y' of 'Math.Pow(double, double)'
You are calling Math.Pow() with just one parameter: Math.Sin(x + y)
and it requires two parameters.
Check the formula and call the Math.Pow
with two parameters, i.e.:
Math.Pow(Math.Sin(x + y), something_here )
I'm not sure what C7036 is but this snippet outputs 8
:
var x = 2;
var y = 3;
var number = Math.Pow(x, Math.Abs(y));
Console.Write(number);
In this example x and y are int
s and number is of type double
.
Upvotes: 2
Reputation: 9461
Try to specify second parameter to your Pow:
Math.Pow(Math.Sin(x + y),SECOND)
in
v = (1 + Math.Pow(Math.Sin(x + y))) /
...
Upvotes: 3