HELP WITH FUNCTIONS

I need to create two functions, the first one must sequence a number. Ex n=6, output 123456.Right now my program outputs 654321. Second I need to create a function that prints these numbers in a triangle.

This is the link to my assignment:
chrome-extension://oemmndcbldboiebfnladdacbdfmadadm/http://venus.cs.qc.cuny.edu/~ctse/111/cs111/slides/hw7.pdf

This is the function I have so far for sequencing the numbers. I have no clue how to create the spaces function for the triangle.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 28 int number(int n)
 29 {
 30         cout << n << endl;
 31 
 32         while(n > 0)
 33         {
 34 
 35                 int digit;
 36                 digit = (n - 1);
 37                 cout << digit << endl;
 38                 n--;
 39         }
 40 }
Hi,

Can you explain why your code produces the numbers in reverse?

With your code, consider using a for loop to count up to n.

For the Triangles, how would you do that on paper? Think about what variables you will need, and how you can repeatedly call your function in a loop. Have a function for each diagram.

Good Luck
Topic archived. No new replies allowed.