# include <iostream>
# include <iomanip>
using namespace std;
int main()
{
int size;
char ch;
do
{
system("cls");
do
{
cout << "Enter the size for the PATTERN (+ve Numbers > 2)?\t";
cin >> size;
if (size < 3)
cout << "Invalid Input.....\n";
} while (size < 3);
int spaces = 1;
int asteric = size - 1;
for (int i = 1; i <= size; i++)
{
cout << setw(40 - size);
if (i == 1)
for (int j = 1; j <= 2 * size - 1; j++)
cout << "*";
else
{
for (int j = 1; j <= asteric; j++)
cout << "*";
for (int j = 1; j <= spaces; j++)
cout << " ";
for (int j = 1; j <= asteric; j++)
cout << "*";
spaces += 2;
asteric--;
}
cout << endl;
}
cout << "Do u want to run Again?(y/n)\t";
cin >> ch;
} while (ch == 'Y' || ch=='y');
return 0;
}
OUTPUT
# include <iostream>
# include <iomanip>
using namespace std;
int main()
{
int size;
char ch;
do
{
system("cls");
do
{
cout << "Enter the size for the PATTERN (+ve Numbers > 2)?\t";
cin >> size;
if (size < 3)
cout << "Invalid Input.....\n";
} while (size < 3);
int spaces = 2 * size - 3;
for (int i = 1; i <= size; i++)
{
cout << setw(40 - size);
if (i == size)
for (int j = 1; j <= 2 * size - 1; j++)
cout << "*";
else
{
for (int j = 1; j <= i; j++)
cout << "*";
for (int j = 1; j <= spaces; j++)
cout << " ";
for (int j = 1; j <= i; j++)
cout << "*";
spaces -= 2;
}
cout << endl;
}
cout << "Do u want to run Again?(y/n)\t";
cin >> ch;
} while (ch == 'Y' || ch == 'y');
return 0;
}
OUTPUT
No comments:
Post a Comment