C program to Integrated triangle patterns using for loop
C program to Integrated triangle patterns using for loop
In this tutorial, we will discuss a concept of C program to Integrated triangle patterns using for loop
In C language, we can use for loop ,while loop and do-while loopto display different number (binary, decimal), alphabets or star pattern programs.
In this article, we are going to learn how toDisplay Integrated triangle patterns using for loop in C language
C code to Integrated triangle star patterns
Integrated Triangle star pattern 1
Program 1
#include
#include
int main()
{
int i,j,k,rows;
printf("Enter the number of rows: ");
scanf("%d",&rows); //get input from user for rows
for(i=1; i<=rows; i++){ //parent for loop
for(j=1; j<=i; j++){
printf("*");
}
for(j=i*2; j=1; k--){
printf("*");
}
printf("\n");
}
getch();
return 0;
}
When the above code is executed, it produces the following results
Integrated triangle patterns
Integrated Triangle star pattern 2
Program 2
#include
#include
int main()
{
int i,j,k,rows;
printf("Enter the number of rows: ");
scanf("%d",&rows); //get input from user for rows
for(i=rows; i>=1; i--){ //parent for loop
for(j=rows; j>=1+rows-i; j--){
printf("*");
}
for(j=i*2; j
When the above code is executed, it produces the following results
Integrated triangle patterns
C code to Integrated triangle number patterns
Integrated Triangle number pattern 1
Program 1
#include
#include
int main()
{
int i,j,k,rows;
printf("Enter the number of rows: ");
scanf("%d",&rows); //get input from user for rows
for(i=1; i<=rows; i++){ //parent for loop
for(j=1; j<=i; j++){
printf("%d",j);
}
for(j=i*2; j=1; k--){
printf("%d",k);
}
printf("\n");
}
getch();
return 0;
}
When the above code is executed, it produces the following results
Integrated triangle patterns
Integrated Triangle number pattern 2
Program 2
#include
#include
int main()
{
int i,j,k,rows;
printf("Enter the number of rows: ");
scanf("%d",&rows); //get input from user for rows
for(i=rows; i>=1; i--){ //parent for loop
for(j=rows; j>=1+rows-i; j--){
printf("%d",j);
}
for(j=i*2; j
When the above code is executed, it produces the following results
Integrated triangle patterns
Integrated Triangle number pattern 3
Program 3
#include
#include
int main()
{
int i,j,k,rows;
printf("Enter the number of rows: ");
scanf("%d",&rows); //get input from user for rows
for(i=rows; i>=1; i--){
for(j=1; j<=i; j++){
printf("%d",j);
}
for(j=i*2; j=1; k--){
if(k!=rows)
printf("%d",k);
}
printf("\n");
}
getch();
return 0;
}
When the above code is executed, it produces the following results