Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,825 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,968 people online right now. Registration is fast and FREE... Join Now!




nested loops for patterns

 
Reply to this topicStart new topic

nested loops for patterns, i need to display 2 seperate patterns of * each row incrementing by on

j2898
3 Oct, 2008 - 09:23 AM
Post #1

New D.I.C Head
*

Joined: 3 Oct, 2008
Posts: 1

cpp
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{


//Dispaly the first pattern
cout << "Pattern A" << endl;

const char plus = '+';
int a = 10;
int x = 0;

while (a > 0)
{
x = a;
while (x < 0)
{
cout << plus;
x = x - 1;
}
a = a - 1;
cout << endl;
}


return 0;
}

MOD EDIT: Please code.gif
Thanks, gabehabe smile.gif
User is offlineProfile CardPM
+Quote Post

realNoName
RE: Nested Loops For Patterns
3 Oct, 2008 - 11:25 AM
Post #2

D.I.C Regular
***

Joined: 4 Dec, 2006
Posts: 299



Thanked: 5 times
My Contributions
change
cpp
      while (x < 0)
{
cout << plus;
x = x - 1;
}


to (all i did is change the < to >)
cpp
      while (x > 0)
{
cout << plus;
x = x - 1;
}

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/3/08 03:22PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month