Skip to content
Home » Dollar and start Pattern Program in C

Dollar and start Pattern Program in C

Learn about Dollar and start Pattern Program in C in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Dollar and start Pattern Program in C

Pattern:

* 
$ * 
* $ * 
$ * $ * 
* $ * $ * 

Program:

#include<stdio.h>
int main()
{
  int n, r, c;

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

  for(r=1; r<=n; r++)
  {
    for(c=1; c<=r; c++)
    {
      if((r+c)%2==0) printf("* ");
      else printf("$ ");
    }

    printf("\n");
  }

  return 0;
}

Output:

Enter number of rows: 5
* 
$ * 
* $ * 
$ * $ * 
* $ * $ * 

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Pattern Program 11 in C
Pattern Programs in C for Floyd’s Triangle