Support us on YouTube by Subscribing our YouTube Channel. Click here to Subscribe our YouTube Channel

Sunday, 25 October 2020

Program to generate Floyd’s Triangle in C#

Floyd’s triangle is a right-angled triangle of natural numbers used in computer science education. Floyd refers to the name after Robert Floyd. Floyd’s triangle is created by printing the consecutive numbers in the rows of the triangle starting from the number 1 at the top left corner.

I will recommend you to check the below link for Top C# Interview Programs asked during the Interview and Examination.
Program:

//Three variable one for outer loop, one for inner

//k to print the number

int i, j, k = 1;

for (i=1;i<=10;i++) {

    for (j=1;j<=i;j++) {

    //Print no. in console with horizontal space i.e. tab

    Console.Write(k++ + "\t");

    }

    //New Line

    Console.Write("\n");

}

//Console.ReadLine() to hold the screen after the execution of the program

Console.ReadLine();

Preview:

I hope this program will help you in your exam as well as Interview preparation.
Thanks

Subscribe us on YouTube

Subscribe Now

Popular Posts

Contact us

Name

Email *

Message *

Like us on Facebook