Use nested loops to produce a pattern - C Statement

C examples for Statement:for

Description

Use nested loops to produce a pattern

$
$$
$$$
$$$$
$$$$$

Demo Code


#include <stdio.h>

int main(void)
{
  for (int i = 1; i < 6; i++)
  {/*from w w w  . jav  a 2s .  c  om*/
    for (int j = 1; j <= i; j++)
    {
      printf("$");
    }
    printf("\n");
  }

  return 0;
}

Result


Related Tutorials