#include
#include
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
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
#include
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
#include
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
#include
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: