using System; public class Test { public static void Main() { var number = Console.ReadLine(); int n = Convert.ToInt32(number); PrintPattern print = new PrintPattern(); print.Printpyramid(n); } } public class PrintPattern { public void Printpyramid(int n) { int dummy=1; for(int i=0;i<n;i++) { for(int j=n;j>i;j--) { if(i==0||j==n||j==dummy) { Console.Write("* "); } else { Console.Write(" "); } } dummy++; Console.WriteLine(); } } }OUTPUT* * * * * * * * * * * * * * *
https://www.geeksforgeeks.org/zoho-interview-set-1-campus/ Given a two dimensional array of string like <”luke”, “shaw”> <”wayne”, “rooney”> <”rooney”, “ronaldo”> <”shaw”, “rooney”> Where the first string is “child”, second string is “Father”. And given “ronaldo” we have to find his no of grandchildren Here “ronaldo” has 2 grandchildren. So our output should be 2. SOLUTION using System; public class Test { public static void Main() { var noOfInputs = Console.ReadLine(); int noOfInputLines = Convert.ToInt32(noOfInputs); string[,] FatherSonArray= new String[noOfInputLines,noOfInputLines]; for(int father=0;father<noOfInputLines;father++) { for(int son=0;son<2;son++) { FatherSonArray[father,son] = Console.ReadLine(); } } Console.WriteLine("No of grandchildrens:"); string GrandFather = Console.ReadLine(); int NoOfGrandSons=0; Console.Wr...
Comments
Post a Comment