Jul 2, 2012 at 3:36am UTC
How to write a program using nested for loop to display the following output:
0
* *
0 1 2
* * * *
0 1 2 3 4
* * * *
* * *
* *
*
Jul 2, 2012 at 4:21am UTC
are those asteriks supposed to be spaces, actual asteriks, or are we to assume we recognize the pattern that it ascends to 01234 then descends back down to 0 like a sideways pyramid?
Jul 2, 2012 at 8:34am UTC
we dont plan on doing your homework for you, give it a shot and come back when you're ready to work.
Jul 3, 2012 at 8:22am UTC
this is what i have, but understand anything
#include <iostream>
using namespace std;
int main()
{
for(int a = 0; a <= 4; a++)
{
for(int b = 0; b <= a; b++)
{
if(a % 2 == 0)
{
cout << b << " ";
}
else
cout << "* ";
}
cout << endl;
}
for(int c = 0; c <= 4; c++)
{
for(int d = 4; d > c; d--)
{
cout <<"* ";
}
cout << endl;
}
system("pause");
return(0);
}