Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,193 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,378 people online right now. Registration is fast and FREE... Join Now!




i need help

 
Reply to this topicStart new topic

i need help, drawings with loops

fatimati
2 Jun, 2008 - 10:06 AM
Post #1

New D.I.C Head
*

Joined: 2 Jun, 2008
Posts: 1

1
21
321
4321
54321
654321

#include<iostream>
using namespace std;



int main()
{

int i, j;
char dummy;

for(i=1; i<=6; i++)
{
for (j=1; j<=i; j++)
cout<< j;
cout<<endl;

}


cin>>dummy;
return 0;
}
User is offlineProfile CardPM
+Quote Post

MorphiusFaydal
RE: I Need Help
2 Jun, 2008 - 10:13 AM
Post #2

D.I.C Lover
Group Icon

Joined: 12 May, 2005
Posts: 1,113



Thanked: 9 times
Expert In: Hardware, Networking

My Contributions
What's the question?
User is offlineProfile CardPM
+Quote Post

gabehabe
RE: I Need Help
2 Jun, 2008 - 10:20 AM
Post #3

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,556



Thanked: 99 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
All you need to do is reverse the loop, like so:
cpp
#include<iostream>

using namespace std;

int main()
{
int i, j;
char dummy;

for(i=1; i<=6; i++)
{
for (j=i; j>0; j--) // reverse the loop, you want to count down
cout<< j;
cout<<endl;
}

cin>>dummy;
return 0;
}

Hope this helps smile.gif

Oh, and welcome to </d.i.c>

This post has been edited by gabehabe: 2 Jun, 2008 - 10:21 AM
User is offlineProfile CardPM
+Quote Post

jjsaw5
RE: I Need Help
2 Jun, 2008 - 11:55 AM
Post #4

I must break you
Group Icon

Joined: 4 Jan, 2008
Posts: 1,411



Thanked: 7 times
Dream Kudos: 125
Expert In: HTML, CSS, Database,

My Contributions
chances are this person will never be back to this site
User is online!Profile CardPM
+Quote Post

gabehabe
RE: I Need Help
2 Jun, 2008 - 11:55 AM
Post #5

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,556



Thanked: 99 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
Why's that?
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 12:05PM

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