Floyd’s triangle number Pattern in C Language using for loop

Floyd’s triangle number Pattern in C Language using for loop

In this article, we will discuss Floyd’s triangle number Pattern in C Language using for loop

In this post, we are going to learn how to create Floyd’s triangle number pattern using for loop

Triangle number Pattern 1

Program 1
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int rowNum,row,coloum;
  printf(“Enter the randomrow numbern”);
  scanf(“%d”,&rowNum);
  for(row=1; row<=rowNum; row++){
      for(coloum=1; coloum<=row; coloum++){
          printf(“%d”,coloum);
      }
      printf(“n”);
      }
 return 0;
  }
Pattern 1

Triangle number Pattern 2

Program 2
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int rowNum,row,coloum;
  printf(“Enter the randomrow numbern”);
  scanf(“%d”,&rowNum);
  for(row=1; row<=rowNum; row++){
      for(coloum=1; coloum<=row; coloum++){
          printf(“%d”,row);
      }
      printf(“n”);
      }
 return 0;
  }
Pattern 2

Triangle number Pattern 3

Program 3
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int rowNum,row,coloum,no=0;
  printf(“Enter the randomrow numbern”);
  scanf(“%d”,&rowNum);
  for(row=1; row<=rowNum; row++){
      for(coloum=1; coloum<=row; coloum++){
              no++;
          printf(“%d”,no);
      }
      printf(“n”);
      }
 return 0;
  }
Pattern 3

 

Triangle number Pattern 4

Program 4

#include <stdio.h>
#include <stdlib.h>

int main()
{
int i,space,rows,k=0, count=0,count1=0;
printf(“Enter number of rows:n”);
scanf(“%d”,&rows);
for(i=1; i<=rows; ++i)
{
for (space=1; space<=rows-i; ++space)
{
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;

}

Pattern 4


Related Article

Suggested for you
Karmehavannan

Recent Posts

Subtract two numbers using method overriding

Subtract two numbers using method overriding   Program 1

3 months ago

PHP Star triangle Pattern program

PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…

3 months ago

Using function or method to Write temperature conversion : Fahrenheit into Celsius

Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…

1 year ago

Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user

Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…

1 year ago

Write temperature conversion program: Fahrenheit into Celsius

Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…

1 year ago

How to write a program to convert Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius In this article, we will…

1 year ago

This website uses cookies.