Author Topic: Number pattern to display triangle with base on bottom  (Read 904 times)

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 69
Number pattern to display triangle with base on bottom
« on: October 26, 2011, 03:09:02 pm »
Here is the code for Number pattern to display triangle with base on bottom

Code:
//Source Code Listing


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

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

dollor

  • Newbie
  • *
  • Posts: 8
Re: Number pattern to display triangle with base on bottom
« Reply #1 on: October 28, 2011, 03:50:32 am »
Thank u sooo much sir for  clearing by solutions

 


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