Hello. So I'm having trouble with c) & d) and I need some help.
Attachment 35097 (http://forums.codeguru.com/attachment.php?attachmentid=35097)
I think I should add cout << " "; somewhere, but I don't know exactly where. Here is my code so far for a) and b). We haven't studied for yet, by the way. We have to use while.
Code:
---------
#include
using namespace std;
int main()
// 1
{
cout << "Pyramid 1" << endl;
int line1 = 1;
do
{
int stars1 = 1;
do
{
cout << "*";
stars1++;
} while (stars1 <= line1);
cout << endl;
line++;
} while (line <= 10);
// 2
cout << "Pyramid 2" << endl;
int stars2 = 10;
int line2 = 1;
while (stars2 != 0)
{
while (stars2 >= red2)
{
cout << "*";
line2++;
}
stars2--;
line2 = 1;
cout << endl;
}
// 3
cout << "Pyramid 3" << endl;
return 0;
}
---------
↧