Math, asked by Mehermalhotra9178, 1 year ago

Return an int array length 3 containing the first 3 digits of pi

Answers

Answered by trumo
0

public static int[] MakePie(int n)

{

double pi = Math.PI;

var str = pi.ToString().Remove(1, 1);

var chararray = str.ToCharArray();

var numbers = new int[n];

for (int i = 0; i < n; i++)

{

numbers[i] = int.Parse(chararray[i].ToString());

}

return numbers;

}

Similar questions