Help with nested loop

Write a function that will generate the following pattern using nested for loop.

+ . . . .
+ + . . .
+ + + . .
+ + + + .


#include <iostream>

using namespace std;


int main()
{
int plus=1;
for(int line=0; line < 3; line++)
{
for(int s=0; s < plus; s++)
cout << "+";
plus +=2;
cout << endl;
}
return(0);
}
PLEASE USE CODE TAGS (the button with <> on it)
That's not the pattern that you want to display. You print
1
2
3
+
+++
+++++

Even for that, you don't need the plus variable. Instead you can loop s to 2*line+1

#include <iostream>

using namespace std;


int main()
{

int plus = 1;
for(int line=0; line < 4; line++)
{
for(int s=0; s < plus; s++)
cout << "+";
plus+=1;
int dot=1;
for(int line=4; line > 0; line--)

for(int p=7; p < dot; p++);


cout << ".";
dot +=2;
cout << endl;
}
return(0);
}


i have improved the code to this put still confused as to how to increase the number of dots on each line. Bear in mind i am an amateur
Dear amateur,
I suspect math is not your strength :))

1
2
3
4
5
6
7
8
9
10
11
12
   int size = 5;


   for(int line=0; line < size; line++) {
      for (int s=0; s < line; s++){
         cout << "+";
      }
      for (int i = line; i < size; i++){
         cout << ".";
      }
      cout << "\n";
   }


Kind regards,
Dean
cheers dean much appreciated
Topic archived. No new replies allowed.