-
January 15th, 2013, 08:38 AM
#1
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
On-Demand Webinars (sponsored)
|