Floyd’s Triangle Number Pattern
Program 1:
#include <stdio.h>
#include <conio.h>
void main()
{
int a,i,j;
printf("Enter number of rows\n");
scanf("%d",&a);
for(i=1; i<=a; i++){
for(j=1; j<=i; j++){
printf("%d",j);
}
printf("\n");
}
1
12
123
1234
12345
123456
1234567
12345678
123456789
#include <conio.h>
void main()
{
int a,i,j;
printf("Enter number of rows\n");
scanf("%d",&a);
for(i=1; i<=a; i++){
for(j=1; j<=i; j++){
printf("%d",j);
}
printf("\n");
}
getch();
}
Expected Output:
Enter the number of rows
9
}
Expected Output:
Enter the number of rows
9
1
12
123
1234
12345
123456
1234567
12345678
123456789
Floyd’s Triangle |
Program 2:
#include <stdio.h>
#include <conio.h>
void main()
{
int a,i,j;
printf("Enter number of rows\n");
scanf("%d", &a);
for(i=1; i<=a; i++){
for(j=1; j<=i; j++){
printf("%d",i);
}
printf("\n");
}
getch();
}
Expected Output:
Enter number of rows
9
1
22
333
4444
55555
666666
7777777
88888888
999999999
Program 3:
#include <stdio.h>
#include <conio.h>
void main()
{
int rows,i,j;
printf("Enter number of rows\n");
scanf("%d", &rows);
for(i=rows; i>=1; i--){
for(j=1; j<=i; j++){
printf("%d",j);
}
printf("\n");
}
getch();
}
Expected Output:
Enter number of rows
9
123456789
12345678
1234567
123456
12345
1234
123
12
1
Program 4:
#include <stdio.h>
#include <conio.h>
void main()
{
int rows,i,j;
printf("Enter number of rows\n");
scanf("%d", &rows);
for(i=rows; i>=1; i--){
for(j=1; j<=i; j++){
printf("%d",i);
}
printf("\n");
}
getch();
}
Expected Output:
Enter number of rows
9
999999999
88888888
7777777
666666
55555
4444
333
22
1
Tags:
c by mskuthar
C Program to print Floyd’s Triangle Number Pattern Using Nested For loop
Floyd’s Triangle Number Pattern
mskuthar