Friday 2 June 2017

Printing patterns


To print a pattern using '*' and dots ( . ):

code:
#include<stdio.h>
void main()
{
    int i,j,k,m,n;
    printf("enter the value for m and n");
    scanf("%d%d",&n,&m);
        for(i=0;i<((3*n)+1);i++)
        {
            for(j=0;j<3*m+1;j++)
            {
                if(i==0||j==0||i%3==0||j%3==0)
                    printf("*");
                else
                    printf(".");
            }
            printf("\n");
        }

}


input: 3 1
output:

****
*. . *
*. . *
****
*. . *
*. . *
****
*. . *
*. . *
****

input: 3 4

output:
*************
*. . *. . *. . *. . *
*. . *. . *. . *. . *
*************
*. . *. . *. . *. . *
*. . *. . *. . *. . *
*************
*. . *. . *. . *. . *
*. . *. . *. . *. . *
*************