Program to print numbers pyramid - Jagrav Education
BANNER 728X90

Tuesday, March 5, 2019

Program to print numbers pyramid

Question : WAP in "C" to find out the following output:


#include <stdio.h>
int main ()
{
  int i, sp, rows, k = 0, count = 0, count1 = 0;

  printf ("Enter number of rows: ");
  scanf ("%d", &rows);

  for (i = 1; i <= rows; ++i)
    {
      for (sp = 1; sp<= rows - i; ++sp)
{
  printf ("  ");
  ++count;
}

      while (k != 2 * i - 1)
{
  if (count <= rows - 1)
    {
      printf ("%d ", i + k);
      ++count;
    }
  else
    {
      ++count1;
      printf ("%d ", (i + k - 2 * count1));
    }
  ++k;
}
      count1 = count = k = 0;

      printf ("\n");
    }
  return 0;
}

2 comments:

Divi read more Text replace with custom text in divi builder via JS Query simple code in wordpress

  use simple JS Query for replace text  <script type="text/javascript"> (function($) { $(document).ready(function() { var ne...