I don't know to Write a full program that can display the following output:

1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
I don't know to write this program because I'm new using C++. can somebody help me??

Recommended Answers

All 10 Replies

Try writing what you want the compiler to do for you in paper, this will help you with the logic of your problem. The rest of the syntax errors the compiler will take care of that for you, for now. Later you will get used to some errors that you wont be making them again.
For now try this code and see if it solves your problem:

#include <iostream>
using namespace std;

int main()
{
    int size=10;                         //set size to where you want to start
    for(int i=10; i>0; i--)            //this is the decrementor for numbers from 10 to 1 for the number of rows you will have
    {
       for(int j=1; j<=size; j++)  //this is the incrementor for the numbers to be displayed
       {
          cout<<j<<" ";
       }
    cout<<endl;
    size--;                                 //size is decremented so as to reduce 1 number in every row
    }
    system("PAUSE");
    return 0;
}
commented: spoon feeder of the week award. -4
commented: You call this help?... +0

Congratulations :(
Not only did you fail to read HOW TO POST CODE in numerous places, you've also spoon-fed an answer without the OP having to do a bloody thing for themselves.

So now they're just going to run off with their nice bone you've thrown them, hand it in for high marks (possibly) and with the delusion that either
a) they can program in C++ (they can't)
b) they can always rely on some schmuck like you too eager to help (possibly true).

THANK YOU CAIA FOR YOUR REPLY. The program is work!!!

Give the guy a break, if he finds programming impossible now he will probably hate it and the trick to being a good programmer is to develop love for the concept so as to have the edge to try out new staff. don't be stereotyped.

commented: Another "in the eye of the beholder" opinion. Don't say things like they're an absolute fact. +0

I like what your saying.... to be a good programmer we must love the program..!!

> THANK YOU CAIA FOR YOUR REPLY. The program is work!!!
Of course it works!
Hundreds of people here "COULD" have given that answer in a few seconds, but that's not why we're here.

Did YOU learn anything about how to write the program?
Probably not. Sure, you can tell a C++ program from a hole in the ground, but that isn't much use.

But since you now seem to be bombing the forum with all your assignments without any effort, I guess you've pretty much given up on learning anything.
You're already behind, and now in free-fall away from the rest of the class.

In the next few weeks, the problems are going to get MUCH harder and you're going to be in no shape to even begin to tackle them unless you get off your arse and actually start posting some of your own code.

commented: Well said XD +3

>I like what your saying.... to be a good programmer we must love the program..!!
To be a good programmer, you need to know how to make a program.

>I like what your saying.... to be a good programmer we must love the program..!!
To be a good programmer, you need to know how to make a program.

Seconded.

These assignments are meant to give you practice, so you can learn what they are trying to teach you. What do you do on exams where you have to sit in class and write the program?

If you are just gonna copy your work, you might as well not finish the class. I strongly suggest not taking the program given to you and attempt to write it yourself. Thats if you want to make it as a programmer.

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.