Author Topic: pattern of numbers example 4  (Read 928 times)

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 69
pattern of numbers example 4
« on: October 29, 2011, 12:21:01 pm »
Enter a number: 5
5 5
4 4
3 3
2 2
1 1
0
1 1
2 2
3 3
4 4
5 5


Code:
//Source Code Listing

int main()
{
   int n = 0;
   printf("Enter a number: ");
   scanf("%d", &n);
   int count = 2;
   for(int i = n; i > 0; i--)
   {
	  for(int j = 0; j < count; j++)
         std::cout << i << " ";
      std::cout << "\n";
   }

   std::cout << "0\n";

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

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

dollor

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

 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1