Floyd Triangle in C Using For Loop

Floyd triangle in c using for loop for beginners to print Floyd’s triangle using looping statement in c programming. Floyd’s triangle is a natural-numbers triangular array used in computer science education. Robert Floyd was the inspiration for the name. Filling the rows of the triangle with successive integers, starting with a 1 in the top left corner, yields the following: 1. 2.

For Loop in C

A for loop is a repetition control structure that allows us to create a loop that runs a set number of times. The loop allows us to do an arbitrary number of steps in a single line. A loop is used to repeatedly execute a set of statements until a certain condition is met.

Stdio.h in Floyd Triangle in C Using For Loop

stdio. h is a C header file that provides C declarations and macro definitions that can be shared across many files. The printf() and scanf() functions are part of the stdio. h standard input/output function.

The acronym STDIO stands for Standard Input-Output. It features various built-in functions, such as int printf() and scanf(). CONIO stands for Console Input-Output and includes functions such as clrscr(), getch(), and others.

#include <stdio.h> 
int main() 
int num, i, j, k = 1; 
printf( "Enter the Number of Rows \n"); 
scanf( "%d", &num); 
for (i = 1; i <= num; i++) 
for (j = 1; j <= i; j++) 
printf(" %2d", k++); 
printf( "\n"); 


Enter the Number of Rows
2 3
4 5 6
7 8 9 10
11 12 13 14 15