hello can you make and run a program that will display the numbers 1,2,3, and so on depending on the number of lines the user will enter.

example output: enter a number=3
1
23
456


thanks for the help..

Recommended Answers

All 6 Replies

Yes.

Yes

No one's complete your homework for you. (It's also discouraged here at DaniWeb)

To get you started, you have to use Nested loops.
The outer loop can control the number of lines, and the inner loop can control the number of numbers per line (which will be the same as line no. )
To obtain the actual numbers which are being displayed, you can use a variable which is initialized to 1 and the incremented as required (figure that out)

Next time please post your own attempt while requesting help..

Hi! can you make and run a program that will display the numbers and so on depending on the number of lines the user will enter.


example if the value of N is 4 the output will be like this:

N=4

4321
321
21
1

thanks ! :))

Hi! can you make and run a program that will display the numbers and so on depending on the number of lines the user will enter.


example if the value of N is 4 the output will be like this:

N=4

4321
321
21
1

thanks ! :))

:yawn: Wow, not only is this a hijack, it's a "givemetehcodez" hijack of an identical "givemetehcodez" :yawn:.
Read this. (Check out the "Keep It Organized" section)
Then read this.
Then try again...

if (n == 1)
cout << "1";
else if (n == 2)
cout <<"1"<<endl<<"23";}
else if (n == 3)
cout <<"1"<<endl<<"23"<<endl<<"456";
else if (n == 4)
...

Repeat the sequence until you reach the maximum possible input for int which is I think 32,767.

After it's done, don't post your code :twisted:

commented: :twisted: Actually, for modern compilers it's about 2.1 billion :twisted: +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.