Skip to main content

Featured

Mastering Hollow Square Patterns in C: Stars, Numbers, Alphabets & Binary

πŸ”’ C Program to Print Hollow Continuous Number Square πŸ“„ Source Code: #include <stdio.h> int main() { int num, k = 0; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { if(i == 1 || i == num || j == 1 || j == num) { // k increments sequentially only along the borders printf("%d ", k++); } else { printf(" "); } } printf("\n"); } return 0; } πŸ“‹ Copy Code πŸ’» Expected Output (Input: 5): Enter the number: 5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 πŸ”’ C Program to Print Standard Hollow Binary Row Square πŸ“„ Source Code (Fixed Specifier): #include <stdio.h> int main() { ...

Triangle Pattern Programs in C with Output

πŸ”’ C Program to Print Continuous Number Triangle Pattern

#include <stdio.h>

int main()
{
    int num, k = 0;

    printf("Enter the number:\n");
    scanf("%d",&num);

    for(int i=1;i<=num;i++)
    {
        for(int j=i;j<=num;j++)
        {
            printf("%d ",k++);
        }

        printf("\n");
    }

    return 0;
}
  

πŸ’‘ Sample Output (Input: 5)

0 1 2 3 4
5 6 7 8
9 10 11
12 13
14
  

πŸ”’ C Program to Print Repeated Binary Triangle Pattern

#include <stdio.h>

int main()
{
    int num;

    printf("Enter the number:\n");
    scanf("%d",&num);

    for(int i=1;i<=num;i++)
    {
        for(int j=i;j<=num;j++)
        {
            printf("%d ",i%2);
        }

        printf("\n");
    }

    return 0;
}
  

πŸ’‘ Sample Output (Input: 5)

1 1 1 1 1
0 0 0 0
1 1 1
0 0
1
  

πŸ”’ C Program to Print Binary Number Triangle Pattern

#include <stdio.h>

int main()
{
    int num;

    printf("Enter the number:\n");
    scanf("%d",&num);

    for(int i=1;i<=num;i++)
    {
        for(int j=i;j<=num;j++)
        {
            printf("%d ",j%2);
        }

        printf("\n");
    }

    return 0;
}
  

πŸ’‘ Sample Output (Input: 5)

1 0 1 0 1
0 1 0 1
1 0 1
0 1
1
  

⭐ C Program to Print Inverted Star Pattern

#include <stdio.h>

int main()
{
    int num;

    printf("Enter the number:\n");
    scanf("%d",&num);

    for(int i=1;i<=num;i++)
    {
        for(int j=i;j<=num;j++)
        {
            printf("* ");
        }

        printf("\n");
    }

    return 0;
}
  

πŸ’‘ Sample Output (Input: 5)

* * * * *
* * * *
* * *
* *
*
  

πŸ”€ C Program to Print Reverse Repeated Alphabet Triangle Pattern

#include <stdio.h>

int main()
{
    int num;

    printf("Enter the number:\n");
    scanf("%d",&num);

    for(int i=num;i>=1;i--)
    {
        for(int j=i;j>=1;j--)
        {
            printf("%c ",i+64);
        }

        printf("\n");
    }

    return 0;
}
  

πŸ’‘ Sample Output (Input: 5)

E E E E E
D D D D
C C C
B B
A
  

πŸ”€ C Program to Print Reverse Alphabet Triangle Pattern

#include <stdio.h>

int main()
{
    int num;

    printf("Enter the number:\n");
    scanf("%d",&num);

    for(int i=num;i>=1;i--)
    {
        for(int j=i;j>=1;j--)
        {
            printf("%c ",j+64);
        }

        printf("\n");
    }

    return 0;
}
  

πŸ’‘ Sample Output (Input: 5)

E D C B A
D C B A
C B A
B A
A
  

πŸ”€ C Program to Print Repeated Alphabet Triangle Pattern

#include <stdio.h>

int main()
{
    int num;

    printf("Enter the number:\n");
    scanf("%d",&num);

    for(int i=1;i<=num;i++)
    {
        for(int j=i;j<=num;j++)
        {
            printf("%c ",i+64);
        }

        printf("\n");
    }

    return 0;
}
  

πŸ’‘ Sample Output (Input: 5)

A A A A A
B B B B
C C C
D D
E
  

πŸ”€ C Program to Print Alphabet Triangle Pattern

#include <stdio.h>

int main()
{
    int num;

    printf("Enter the number:\n");
    scanf("%d",&num);

    for(int i=1;i<=num;i++)
    {
        for(int j=i;j<=num;j++)
        {
            printf("%c ",j+64);
        }

        printf("\n");
    }

    return 0;
}
  

πŸ’‘ Sample Output (Input: 5)

A B C D E
B C D E
C D E
D E
E
  

πŸ”’ C Program to Print Repeated Number Triangle Pattern

#include <stdio.h>

int main()
{
    int num;

    printf("Enter the number:\n");
    scanf("%d",&num);

    for(int i=1;i<=num;i++)
    {
        for(int j=i;j<=num;j++)
        {
            printf("%d ",i);
        }

        printf("\n");
    }

    return 0;
}
  

πŸ’‘ Sample Output (Input: 5)

1 1 1 1 1
2 2 2 2
3 3 3
4 4
5
  

πŸ”’ C Program to Print Descending Number Pattern

#include <stdio.h>

int main()
{
    int num;

    printf("Enter the number:\n");
    scanf("%d",&num);

    for(int i=1;i<=num;i++)
    {
        for(int j=i;j<=num;j++)
        {
            printf("%d ",j);
        }

        printf("\n");
    }

    return 0;
}
  

πŸ“ Explanation:

This C program prints a descending number pattern using nested loops. The outer loop controls the rows, while the inner loop prints numbers starting from the current row number up to the entered number.

πŸ’‘ Sample Output (Input: 5)

1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
  

Comments

Popular Posts

πŸŒ™