C++ Shapes Code

2 comments















































 














0032
right triangle 
upside down triangle using ABCED




0036
right triangle 
up side down triangle using 1234








2 Questions:

Ahmed Sohail 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;
}

}

Popular Posts