Floyd's triangle

C program to Floyd’s triangle star pattern

C program to Floyd’s triangle star pattern

In this tutorial, we will discuss the C program to Floyd’s triangle star pattern.

This post to described how to create  Floyd’s triangle star pattern using nested for loop in C language

Program 1

Code to Floyd’s triangle star pattern 1

 

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

int main()
{
    int i,j,rows;
    printf("Enter number of rows you want: ");
    scanf("%d",&rows);//Input number of rows from user

    for(i=1; i<=rows; i++){//parent for loop for literate rows

            for(j=i; j<rows; j++){//print space using this for loop
                printf(" ");
            }

            for(j=1; j<=i; j++)//print star through every rows
            {
                printf("*");
            }
            printf("\n"); //move to next line

    }
     getch();
    return 0;
}

When the above code is executed, it produces the following results:

floyd’s triangle pattern 1

 

Program 2

Code to Floyd’s triangle star pattern 2

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

int main()
{
    int i,j,rows;
    printf("Enter number of rows you want: ");
    scanf("%d",&rows);//Input number of rows from user

    for(i=1; i<=rows; i++){//parent for loop for literate rows

            for(j=1; j<=i; j++){//print star for pattern
                    printf("*");
            }
            printf("\n"); //move to next line

    }
     getch();
    return 0;
}

 

When the above code is executed, it produces the following results:

Triangle pattern 2

Program 3

Code to Floyd’s triangle star pattern 3

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

int main()
{
    int i,j,rows;
    printf("Enter number of rows you want: ");
    scanf("%d",&rows);//Input number of rows from user

    for(i=1; i<=rows; i++){//parent for loop for literate rows

            for(j=i; j<=rows; j++){//print star for pattern
                    printf("*");
            }
            printf("\n"); //move to next line

    }
     getch();
    return 0;
}

When the above code is executed, it produces the following results:

Triangle pattern 3

Program 4

Code to Floyd’s triangle star pattern 4

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

int main()
{
    int i,j,rows;
    printf("Enter number of rows you want: ");
    scanf("%d",&rows);//Input number of rows from user

    for(i=1; i<=rows; i++){//parent for loop for literate rows

            for(j=1; j<=i; j++){//print star for pattern
                    printf(" ");
            }
            for(j=i; j<=rows; j++){//print star for pattern
                    printf("*");
            }
            printf("\n"); //move to next line

    }
     getch();
    return 0;
}

When the above code is executed, it produces the following results:

Triangle pattern 3

 

Suggested for you

For loop in Java language

For loop in C++ language

For loop in C language

For loop in Python language

 

While loop in Java language

While loop in C language

While loop in C++ language

While loop in Python language

 

Do-while loop in Java language

Do-while loop in C language

Do-while loop in C++ language

 

Similar post

Java program to print star pyramid pattern 

C program to print star pyramid pattern 

C++ program to print star pyramid pattern 

Python program to print star pyramid pattern 

Floyd’s triangle number pattern using for loop in C

Floyd’s triangle pattern using nested for loop in Java

Floyd’s triangle pattern using nested while loop in Java

 

Hollow triangle pattern in C programming
Java code to Floyd's triangle star pattern
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

How to find reverse number using method in Java

How to find reverse number using method In this article, we will discuss the concept…

23 hours ago

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago