Final exam question #1

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s