Patterns Programs in C++
Patterns Programs in C++
Anushree
K. Rewale
***** #include<iostream>
**** using namespace std;
int main()
*** {
** int i, j, k;
* for(i = 1; i <= 5; i++)
{
11111 /* Print spaces in increasing order of row */
2222 for(j = 1; j < i; j++)
{
333 cout<<" ";
44 }
5 /* Print star in decreasing order or row */
for(k = 5; k >= i; k--)
{
54321 cout<<"*"; //replace " * " with i & k variable
5432 }
543 /* Move to next line */
54 cout<<"\n";
}
5 return 0;
}Prepared by Prof. Anushree K. Rewale
* #include<iostream>
using namespace std;
***
int main()
***** {
******* int i, j, k;
for(i = 1; i <= 5; i++)
*********
{
/* Print spaces in decreasing order of row */
1 for(j = i; j < 5; j++)
222 {
33333 cout<<" ";
4444444 }
/* Print star in increasing order or row */
555555555
1 for(k = 1; k < (i*2); k++)
123 {
cout<<"*"; //replace " * " with i & k variable
12345 }
1234567 /* Move to next line */
123456789 cout<<"\n";
}
return 0;
}Prepared by Prof. Anushree K. Rewale
*********** #include<iostream>
***** using namespace std;
int main()
***** {
*** int i, j, k;
for(i = 5; i >= 1; i--)
*
{
55555555544 /* Print spaces in increasing order of row */
44444 for(j = 5; j > i; j--)
{
33333 cout<<" ";
222 }
1 /* Print star in decreasing order or row */
for(k = 1; k < (i*2); k++)
{
12345678912 cout<<"*"; //replace " * " with i & k variable
34567 }
12345 /* Move to next line */
123 cout<<"\n";
}
1 return 0;
}Prepared by Prof. Anushree K. Rewale
* #include<iostream>
** using namespace std;
int main()
***
{
**** int i, j, k;
***** for(i = 1; i <= 5; i++)
{
1 for(j = i; j < 5; j++)
{
22 cout<<" ";
333 }
4444 for(k = 1; k <= i; k++)
55555 {
1 cout<<"*"; //replace " * " with i & k variable
12 cout<<" ";
}
123
cout<<"\n";
1234 }
12345 return 0;
}
Prepared by Prof. Anushree K. Rewale
********* #include<iostream>
*** using namespace std;
int main()
**
{
* int i, j, k;
for(i = 1; i <= 5; i++)
111112222 {
333 for(j = 1; j < i; j++)
{
44
cout<<" ";
5 }
for(k = 5; k >= i; k--)
{
543215432 cout<<"*"; //replace " * " with i & k variable
cout<<" ";
543 }
54 cout<<"\n";
5 }
return 0;
}
Prepared by Prof. Anushree K. Rewale