Pyramid Output: 1 212 32123 4321234 543212345 ........................ ........................ The Code Explained by below: //Ex. 4321234 - Here "432" - first part and "1"-Middle part then "234" - Second part. //StringBuilder is the bsest option for printing the sequnce numbers in same row /line. var sbObj = new StringBuilder(); int n = 5; // ToDO-Read the input from Console for (int i = 1; i <= n; i++) { if (i == 1) sbObj.AppendLine(i.ToString()); else { int k = i; //Assign i value to k because we can not reduce or increment i. why means it will affect main for loop. int e = 0; // This property is going to help out the right outer section like 1234 (ex: 4321234) for (int j = 0; j < i; j++) // This loop helps out the printing number
- Get link
- X
- Other Apps