Hello! I am trying to write a program that has three files, two .cpp and one .h
one of the .cpp files is details the function for the .h and im having trouble getting it to compile. I know it has to do with using return and i dont know how the code shoud look.
Below is the functions .cpp
#include "figures.h"
int filledSquare(int a)
{
for (int b = 0; b < a; b++) //first figure
{
for (int c = 0; c < a; c++)
cout << "*";
cout << endl;
}
cout << endl;
}
int leftTriangle(int a)
{
return (int b = a; b > 0; b--) //second figure
{
for (int c = 0; c < b; c++)
cout << "*";
cout << endl;
}
cout << endl;
}
int rightTriangle(int a)
{
return (int b = 0; b < a; b++) //third figure
{
int s = a - b; //calculates number os stars to print
for (int c = 0; c < b; c++)
cout << " ";
for (int c = 0; c < s; c++)
cout << "*";
cout << endl;
}
cout << endl;
}
int hollowSquare(int a)
{
return (int b = 0; b < a; b++) //fourth figure
{
int s = a - 2;
if (b == 0 || b == (a - 1))
{
for (int c = 0; c < a; c++)
cout << "*";
cout << endl;
}
else
{
cout << "*";
for (int c = 0; c < s; c++)
cout << " ";
cout << "*";
cout << endl;
}
cout << endl;
}
.h file
1 2 3 4
int filledSquare(int);
int leftTriangle(int);
int rightTriangle(int);
int hollowSquare(int);
I changed the function .cpp so that there is no return on each function. So now the only errors im receiving are from those functions not returning a value. I'm not sure how to write that part in the functions themselves.
Shameless self bump, really stuck on this. Also i believe that for choosing a filled or hollow square, i do not have the correct code to have the user enter f for filled or h for hollow.