Write a program that takes input of the number of rows and then prints the diamond for the given number of rows using loops
Sample diagram
A
BCD
EFGH
IJKLMN
OPQRS
UWX
Y
#include <iostream>
using namespace std;
int main()
{
int i = 0;
for (char c = 'A'; c <= 'Y'; c++)
{
if(c!='T'&&c!='V')
cout << c;
if (i == 0)
cout << endl<<endl;
if(i==3)
cout << endl<<endl;
if (i == 7)
cout << endl<<endl;
if (i == 13)
cout << endl << endl;
if (i == 18)
cout << endl << endl;
if (i == 23)
cout << endl << endl;
i++;
}
}
Comments
Leave a comment