// Adams, Christopher
// Lab4 exercise2
// This program creates two triangles based on user input. The first triangle is displayed and the second triangle is the inverse of the first triangle.
#include "stdafx.h"
#include <iostream>
using namespace std;
void printTriangle (int);
void printTriangle2 (int);
int base = 0;
int main(void)
{
cout << "Enter the size of your base: ";
cin >> base;
cout << endl;
printTriangle (base);
printTriangle2 (base);
}
void printTriangle (int prntTri)
{
for(int i = 0; i < prntTri; i++)
{
for(int j = 0; j <= i; j++)
{
cout << "*";
}
cout<<endl;
}
}
void printTriangle2 (int prntTri)
{
for(int i = 0; i < prntTri; i++)
{
for(int j = prntTri; j > i; j--)
{
cout << "*";
}
cout<<endl;
}
}
I am supposed to write a program that uses functions to display a triangle based on the user's input and the inverse of that same triangle. I got this program to do just that, but the second function is supposed to be an overloaded function of the first function. I'm not exactly sure how overloaded functions work, can anybody help?

New Topic/Question
Reply



MultiQuote




|