C# Number Pattern (24) |
1: /* C# program to print the following pattern
2: 1
3: 2 3 4
4: 5 6 7 8 9 */
5: namespace Patterns
6: {
7: class Program
8: {
9: static void Main(string[] args)
10: {
11: int i, j, k;
12: k = 1;
13: for (i = 1; i <= 5; i += 2)
14: {
15: for (j = 5; j >= 1; j--)
16: {
17: if (j > i)
18: Console.Write(" ");
19: else
20: Console.Write(" " + k++);
21: } Console.WriteLine();
22: }
23: }
24: }
25: }
No comments:
Post a Comment