A tutorial video on how to do the “triangle” function for the final exam. Link and code bellow:

#include <iostream>

using namespace std;

int triangle (int size)

{

for(int c1=0; c1<=size; c1++)

{

for (int c2=0; c2<c1; c2++)

{

cout<<“T”;

}

cout<<endl;

}

for (int c1=size-1; c1>0; c1–)

{

for (int c2=c1; c2>0; c2–)

{

cout<<“T”;

}

cout<<endl;

} return 0;

}

int main()

{

int size;

cout<<“Give me the size of your pyramid”<<endl;

cin>>size;

cout<<triangle(size)<<endl;

return 0;

}

Advertisements