| 1. |
Coding for pattern in diamond shape such that 1.121.12321.121.1 |
|
Answer» Coding Language not specified so I'll give you the answer in C++ LANGUAGE. CODE: #include using namespace std; int MAIN() { int i, space, rows, k = 0, count = 0, count1 = 0; cout<< "Dking is great\n"; cout << "Enter the number of rows: "; cin >> rows; for (i = 1; i <= rows; ++i) { for (space = 1; space <= rows - i; ++space) { cout << " "; ++count; } while (k != 2 * i - 1) { if (count <= rows - 1) { cout << i + k << " "; ++count; } { ++count1; cout << i + k - 2 * count1 << " "; } ++k; } count1 = count = k = 0; cout << "\n"; } return 0; } PASTE IT ON COMPILER OR READ IT TO GET THE IDEA HOPE YOU LIKE IT OUTPUT: Enter the number of rows: 5 1 2 3 2 3 4 5 4 3 4 5 6 7 6 5 4 5 6 7 8 9 8 7 6 5 |
|