NOTE: (w)- represent as SPACE. i really do everythng but still i can't get this kind of output. so please guys i need your help. my Proffesor might give this kind of output for our finals. :))))))) TNX
On nth line there are 8-n spaces and n stars. That will be three for loops. There really isn't anything else to say. Maybe if you showed an effort, I could say what you did wrong.
NOTE: in this i code i can loop the spaces (w) as shown in my output above.
base on my knowledge. this problem has 3 for loops.(sorry for my grammar).the variable "z" is the one that i will put on the 3rd loop.
for( )
{
for( )
}
for( )
- just like this. but i really dont know what is the condition in the 3rd LOOP. i tried a lot to run it correctly.
so sir can u give me the exact code for the 3rd LOOP?. i really getting a hard time on this one. tnx a lot.
The second loop goes down from 5 to x (as you implemented it)
The third loop goes up from 0 to x (which is very much like the second loop just with ++ and <)
#include<iostream.h>
#include<conio.h>
main()
{
int x,y,z;
for(x=1;x<=5;x++)
{
for(y=5;y>=x;y--)
{
cout<<" ";
cout<<endl; // this prints a newline character--you want only 1 of these per line (at the end)
}
for(z=1;z<=x;z++)
{
cout<<"*";
cout<<endl;
}
} // this was missing
getch();
return 0;
}
Getting closer... Just think about the output you want (character by character) and make the program output that. Remember, 1 newline per line of output.
Here's a nice way to think of the outer loop:
for(x=1;x<=5;x++) // read this as, "for each line"