Hello, I would like some help with this homework problem. I have to create a c++ program that will output this triangle pattern:
http://gyazo.com/124b7f7235749e8cdf0367eb29483000.png
This is my attempt:
http://gyazo.com/124b7f7235749e8cdf0367eb29483000.png
This is my attempt:
#include <iostream> #include <cstdlib> using namespace std; int main() { //First Triangle for (int i = 0; i <= 10; i++) //this prints stars as rows { for (int j = 0; j < 10; j++) //this prints stars as columns { if (j == i) { cout << "*"; } else { cout << " "; } } cout << endl; } //Second triangle for (int i = 0; i <= 10; i++) //this prints stars as rows { for (int j = 0; j < 10; j++) //this prints stars as columns { if (j == i) { cout << " "; } else { cout << "*"; } } cout << endl; } //Third Triangle for (int i = 0; i <= 10; i++) //this prints stars as rows { for (int j = 0; j < 10; j++) //this prints stars as columns { if (j == i) { cout << " "; } else { cout << "*"; } } cout << endl; } //Fourth Triangle for (int i = 0; i <= 10; i++) //this prints stars as rows { for (int j = 0; j < 10; j++) //this prints stars as columns { if (j == i) { cout << "*"; } else { cout << " "; } }cout << endl; } }