Software & Finance Forums

### Author Topic: pattern of numbers example #1  (Read 1063 times)

• Full Member
• Posts: 69
##### pattern of numbers example #1
« on: October 26, 2011, 10:26:18 am »
write a program to display the numbers in the following format
4 4
3 3 3 3
2 2 2 2 2 2
1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1
2 2 2 2 2 2
3 3 3 3
4 4

Source code:
Code:
```//Source Code Listing

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

for(int i = n; i >= 0; i--)
{
for(int j = 0; j < n - i + 1; j++)
std::cout << i << " ";
std::cout << "\n";
}

for(int i = 1; i <= n; i++)
{
for(int j = 0; j < n - i + 1; j++)
std::cout << i << " ";
std::cout << "\n";
}

return 0;
}
```
« Last Edit: November 01, 2011, 05:43:38 pm by kathir »

#### dollor

• Newbie
• Posts: 8
##### Re: pattern of numbers example #1
« Reply #1 on: October 28, 2011, 03:55:05 am »
Thank you sir!!

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