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

Multiply two numbers in Java using scanner| 5 different ways

Multiply two numbers in Java using scanner| 5 different ways In this article, we will…

9 months ago

5 different ways to Divide two numbers in Java using scanner

5 Different ways to Divide two numbers in Java using scanner In this article, we…

10 months ago

Learn 8 Ways to Subtract Two Numbers Using Methods in Java

Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…

10 months ago

10 ways to subtract two numbers in Java

10 ways to subtract two numbers in Java In this article, we will discuss the…

10 months ago

Java Code Examples – Multiply Two Numbers in 5 Easy Ways

Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…

10 months ago

How to Divide two numbers in Java| 5 different ways

How to Divide two numbers in Java| 5 different ways In this article, we will…

10 months ago

This website uses cookies.