Pattern Printing

Problem:
****
***
**
*

code:

#include<stdio.h>
int main()
{
    int i,j;
    for(i=1; i<=4; i++)
    {
        for(j=i; j<=4; j++)
        {
            printf("*");
        }
        printf("\n");
    }
    return 0;
}

Problem:
*
**
***
****
code:

#include<stdio.h>
int main(){

int i,j;
for(i=1;i<=4;i++)
{
    for(j=1;j<=i;j++)
    {
        printf("*");
    }
    printf("\n");
}
return 0;
}

Problem:
*
Blank Line
***
Blank Line
*****
Blank Line
*******
code:

#include<stdio.h>
int main()
{
    int i,j;
    for(i=1;i<=7;i++)
    {
     if(i%2==0)
     {
         printf("Blank Line\n");
     }
     else
     {
         for(j=1;j<=i;j++){
         printf("*");
         }
         printf("\n");
     }
    }
    return 0;
}

Problem:
1
12
123
1234
12345
code:

#include<stdio.h>
int main(){
int  i,j;
for(i=1;i<=5;i++)
{
    for(j=1;j<=i;j++)
    {
    printf("%d",j);
    }

 printf("\n");
}


return 0;
}

problem:
12345
1234
123
12
1

code:

#include<stdio.h>
int main(){
int  i,j;
for(i=5;i>=1;i--)
{
 for(j=1;j<=i;j++)
 {
     printf("%d",j);
 }
 printf("\n");
}
return 0;
}

Problem:

***
**
*

code:

#include<stdio.h>
int main()
{

    int i,j,k,l;
    for(i=0; i<3; i++)
    {
        for(j=0; j<i; j++)
        {
            printf(" ");
        }
        for(k=2; k>=i; k--)
        {
            printf("*");
        }
        printf("\n");
    }
    return 0;
}

Problem:

*****
 ***
  *

code:

#include<stdio.h>
int main()
{

    int i,j,k,l;
    for(i=0; i<3; i++)
    {
        for(j=0; j<i; j++)
        {
            printf(" ");
        }
        for(k=2; k>=i; k--)
        {
            printf("*");
        }
        for(l=2; l>i; l--)
        {
            printf("*");
        }
        printf("\n");
    }
    return 0;
}

Problem:

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

code:

#include<stdio.h>
int main()
{

    int i,j,k,l;
    for(i=0; i<3; i++)
    {
        for(j=0; j<i; j++)
        {
            printf(" ");
        }
        for(k=2; k>=i; k--)
        {
            printf("*");
        }
        for(l=2; l>i; l--)
        {
            printf("*");
        }
        printf("\n");
    }
    for(i=0;i<2;i++)
    {
        for(j=2;j>i+1;j--)
        {
            printf(" ");
        }
        for(k=0;k<=i+1;k++)
        {
            printf("*");
        }
        for(l=0;l<i+1;l++)
        {
            printf("*");
        }
        printf("\n");
    }
    return 0;
}

problem:

1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
6 12 18 24 30 36

code:

#include<stdio.h>
int main()
{
    int i,j;
    for(i=1; i<=6; i++)
    {
        for(j=i; j<=i*i; j=j+i)
        {
            printf("%d\t",j);
        }
        printf("\n");
    }
    return 0;
}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *