Software & Finance Forums

### Author Topic: Diamond pattern of numbers  (Read 1345 times)

• Full Member
• Posts: 69
##### Diamond pattern of numbers
« on: October 26, 2011, 02:57:32 pm »
Here is the program to display diamond pattern of numbers.

Code:
```//Source Code Listing

void main()
{
int i, j, k, n = 0;
printf("Enter a number: ");
scanf("%d", &n);

for (i = 1; i <= n; i++)
{
for (j = 0; j < (n - i)* 2; j++)
printf(" ");
for (j = 1; j <= i; j++)
printf("%d ", i);
for (k = 1; k < i; k++)
printf("%d ", i);
printf("\n");
}

for (i = n - 1; i >= 1; i--)
{
for (j = 0; j < (n - i) * 2; j++)
printf(" ");
for (j = 1; j <= i; j++)
printf("%d ", i);
for (k = 1; k < i; k++)
printf("%d ", i);
printf("\n");
}
std::cout << "\n\n";
}
```
« Last Edit: November 01, 2011, 05:44:50 pm by kathir »

#### dollor

• Newbie
• Posts: 8
##### Re: Diamond pattern of numbers
« Reply #1 on: October 28, 2011, 03:52:44 am »
your awesome sir!! thank you with the output sir

Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.