Header Ads Widget

What's the simplest way to learn pattern programs in C language?

Sometimes we see  that  a loop is written inside body of another loop-

for( i = 1 ; i <= n ; i++)
{
  for( j = 1 ; j <= n ; j++)
  {
     ........
     ........
  }
}
It is called nesting of loops.  Any type of loop can be nested inside any other type of loop.

  Consider a pattern -
  
  *
  * *
  * * *
For this we can write a C code as :

for( i = 1 ; i <= 3 ; i++)
{
  for( j = 1 ; j <= i ; j++)
  {
     printf("* ");
  }
  printf("\n");
}

Post a Comment

0 Comments