Start New Discussion within our Software Development Community

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! :)

first things first
seeing that your in your first semester of c++, use knowledge you have obtained in prior classes, look over your old notes.
Chances are if your prof wants it done a specific way he would have taught you how.
Secondly, if you want to be fancy you could look into #include <iomanip>, play around with that header.

http://msdn.microsoft.com/en-us/library/daeb650d(v=VS.80).aspx

This article has been dead for over six months. Start a new discussion instead.