C++ Shapes Code

11 comments















































 














0032
right triangle 
upside down triangle using ABCED




0036
right triangle 
up side down triangle using 1234








11 Questions:

Unknown said...

how to form such pattern use for loop
1234567654321
123456 654321
12345 54321
1234 4321
123 321
12 21
1 1

Muhammad Iqbal said...

#include
using namespace std;
/*
1234567 7654321
123456 654321
12345 54321
1234 4321
123 321
12 21
1 1
*/

void main() {
int n = 8;
int p = n - 1;
for (int i = n; i >= 0; i--) {

for (int j = 1; j < i; j++) {
cout << j;
}
cout << " ";
for (int k = p; k > 0; k--) {
cout << k;

}
p--;
cout << endl;
}

}

Unknown said...

how to print following shape?
*****
* *
*
* *
*****
anyone??

Unknown said...

Please give me the code in C++
5 * * * *
* 4 * * *
* * 3 * *
* * * 2 *
* * * * 1

Unknown said...

If we make a function call DrawBox(int h,int w) with h=5 and w=5, the following should print:

*****
*0*0*
*****
*0*0*
*****

Unknown said...

If we make a function call DrawBox(int h,int w) with h=5 and w=5, the following should print:

*****
*0*0*
*****
*0*0*
*****

Unknown said...

//FOR
//5 * * * *
//* 4 * * *
//* * 3 * *
//* * * 2 *
//* * * * 1
#include
using namespace std;
int main()
{
int i, j, r = 5;

for (i = 1; i <= 5; i++)
{
for (j = 1; j <= 5; j++)
{
if (i == j)
{
cout << r;
r = r - 1;
}
else
{
cout << "*";
}
}
cout << endl;
}
return 0;
}

Unknown said...

*
**
* *
* *
******
how to make that code

Unknown said...

*
* *
* *
**************

how to make that code

Unknown said...

+------+
| ^^ |
| ^ ^ |
|^ ^|
| ^^ |
| ^ ^ |
|^ ^|
+------+
|v v|
| v v |
| vv |
|v v|
| v v |
| vv |
+------+
how to print this

Unknown said...

+------+
| ^^ |
| ^ ^ |
|^ ^|
| ^^ |
| ^ ^ |
|^ ^|
+------+
|v v|
| v v |
| vv |
|v v|
| v v |
| vv |
+------+
how to print this.