Convert this program into pyram1d
Hi there,
I have this program here I have written recently. Now I am trying very hard to convert this into a pyramid. I am not able to make any logic of it. I hope you can help me out. Here is my code:
#include <iostream>
#include <conio.h>
using namespace std;
void main()
{
int number, temp;
cout << "Enter a number: ";
cin >> number;
temp = number;
for (int i = 1 ; i <= number; i++)
{
for (int j = 1; j<=temp; j++)
cout << j;
temp--;
cout << endl;
}
getch();
}
Output:
12345
1234
123
12
1
I want the output of this program to be in a pyramid. Like;
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
I hope you can help me out. Thanks for your time.
Re: Convert this program into pyram1d
Sorry , i have written wrong above , i want the output in the pyramid
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Re: Convert this program into pyram1d
Quote:
Originally Posted by
wikki2013
Code:
Output:
12345
1234
123
12
1
I want the output of this program to be in a pyramid. Like;
Code:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
I hope you can help me out. Thanks for your time.
If you want to have the formatted post here in the Forum then, please, use Code tags!
The same Code tags you have to use around your code snippets. Otherwise your code in unreadable!