Hi! I'm new this semester to C++ and it is a little difficult for me. Our class has a project where we need to implement functions.
While I got the very first one right, I'm not sure what to do about the others that are similar to it. Can anyone help me/let me know what I should do?
//Requires: n > 0
//Modifies: nothing
//Effects: prints a right triangle
// with a parameter of 3 gives
//*
//**
//***
void printRight(int n)
{
int y, z;
for(int y = 0; y < n; ++y) //Initializes y, makes it less than n and increases the y count.
{
for(int z = y; z >= 0; --z) //Initializes z as equal to y, and decreases the number of *s.
{
cout << "*";
}
cout << endl;
}
}
//Requires: n > 0
//Modifies: nothing
//Effects: prints a right triangle with the *'s right justified
// with a parameter of 3 gives
// *
// **
//***
void printRight_rightJustified(int n);
//How do I make spacing different? Do I need to implement cout<<" "; If so, how would I do this?
//Requires: n > 0
//Modifies: nothing
//Effects: prints a right triangle upside down
// with a parameter of 3 gives
//***
// **
// *
void printRight_upsideDown_rightJustified(int n);
//I'm not sure how to start here. I've done multiple tries but just had infinite *'s while running the builds
//Requires n > 0
//Modifies: nothing
//Effects: prints a right triangle upside down
// with a parameter of 3 gives
//***
//**
//*
void printRight_upsideDown(int n);
//I'm sure I'll figure out this one if I can get help on the other two please?
Thanks! :)