+ 4
How to make half pyramid in c++?
Can anyone tell me the logic behind making of pyramid in c++ whether it's half pyramid or full pyramid
12 Answers
+ 2
Nested loops .
+ 2
Eddy M for(I=0;I<=5;I++) {
For(j=0;j<=I;j++) {
Cout<<"*";
}
Cout<<endl;
}
+ 2
In innerloop you write j<i how is your code still working because 1 is not less than 1 you have to add <= sign I think correct me if I am wrong
+ 1
Eddy M I just want to how inner for loop working what is the use of j++ in second loop
+ 1
Nitin Bisht
j++ counts every "*" on a line until you reach I, the number of the line.
You need to declare int I and int j before using them and you probably wanted to write cout, not Cout and for instead of For.
I guess your editor did the capitalization.
0
It's a combination of triangle. First triangle is made of " "(empty space...) Then the second one is of *
you have to make both the triangles simultaneously
0
Beegcat, I can't figure out the code for half pyramid like in first row there is one star, in 2nd row there is 2 star and in 3rd row there is 3 star and so on to 5th row .
0
You already noticed in Nth row there are N stars, can you write the code now?
0
Eddy M yes
0
Nitin Bisht
Try replacing:
cout<<"*"; with cout<<i; and run it (use I if you still have it like that)
then
cout<<"*"; with cout<<j; and run it
I hope you will understand how i and j work in the codes.
- 2
Eddy M do you know html table also?