* * * * *
_ * * * *
_ _ * * *
_ _ _ * *
_ _ _ _ *
can someone show me the code for this program using
"FOR LOOPS"

thanks.....

4
Contributors
11
Replies
12
Views
10 Years
Discussion Span
Last Post by chirru

post the code you have written and we'll try to help you.

but i cant create a code for this triangle...
sorry but i dont know...
can you help me make one?...

Didn't your momma ever tell you that "can't never did anything". What's the first thing you have to do? Answer: write a program with main() function. Next: create a loop that counts from 0 to 5. Do you know what a loop is? If not, then read your textbook and it will tell you with examples.

i know ok ill make....
this is the code for a left triangle i know.....

``````#include<iostream.h>
main()
{
int x;
int y;
int z;
for(x=0;x<6;x++){
for(y=6;y>x;y--){
cout<<"    ";
}
for(z=0;z<y;z++){
cout<<"  * ";
}
cout<<"\n\n\n";
}
getchar();
return 0;
}``````

this is the figure....
_ _ _ _ *
_ _ _ * *
_ _ * * *
_ * * * *
* * * * *

ill have this triangle but im using SPACING to create this......

* * * * *
_ * * * *
_ _ * * *
_ _ _ * *
_ _ _ _ *
can someone show me the code for this program using
"FOR LOOPS"

``````#include <iostream>
#include <string>

using namespace std;

#define FOR_LOOPS cout << "* * * * *\n_ * * * *\n_ _ * * *\n_ _ _ * *\n_ _ _ _ *";

int main()
{
FOR_LOOPS

cin.get();
return 0;
}``````
+_+ this is funny
You could have done it with FOUR loops as well if you wanted to ;)
Is this from the "F-ugly code club"? :D

>>ill have this triangle but im using SPACING to create this......
That's what you're supposed to do. Just reverse the order of the spaces and start, and you should get what you want.

Stop being such a sponge and try things.

I could, but I won't. Try to do this yourself so that you will learn something. Afterall, isn't that what school is all about?

but i really dont know how to do this in reverse >_<

Did you write that code you posted or not? My guess is you got it from someone else. Study the code and think about what it is doing. Then see if you can see how to rearrance a few lines to make it do what you want it to do. If you don't understand the program you posted then I don't know how we can help you.

``````#include <stdio.h>

main()
{
const int N = 5;
int Value[N];

for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
if( i > j )
printf("-");
else
printf("*");
}
printf("\n");
}
}``````
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.