0

Can anyone explain me for understanding ?

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static int Pow(int x, int y=2) { int result = 1; for (int i = 0; i < y; i++) { result *= x; } return result; } static void Main(string[] args) { Console.WriteLine(Pow(6)); Console.WriteLine(Pow(3, 4)); } } }

30th Jan 2020, 5:44 PM
Ehsan Wattoo
3 odpowiedzi
+ 5
First time when you make a call to the function Pow(6), then 6 is copied to x and y=2 is used for further processing since there was only a single argument passed. In the second case when function Pow(3,4) is called, 3 is copied to x and 4 is copied to y. Hope you can make out what is happening inside the function.
30th Jan 2020, 5:49 PM
Avinesh
Avinesh - avatar
0
Avinesh Thanksss bro
30th Jan 2020, 5:56 PM
Ehsan Wattoo