Did Problem 9 and 10 in Csharp