Hash Asterisk Alternate Pattern

The program must accept an integer N as the input. The program must print the desired hash asterisk alternate pattern as shown in the Example Input/Output section.

Boundary condition(s):
2 <= N <= 100

Input Format:
The first line contains N.

Output Format:
The first N lines contain the desired pattern as shown in the Example Input/Output section.

Example Input/Output 1:
Input

4
Output
##
##
##
##

Example Input/Output 2:
Input

5
Output
###
##*
###
##*
###

#include<stdlib.h>
#include<stdio.h>
int main()
{
int a;
char k='*';
scanf("%d",&a);
for (int i=1;i<a;i++)
{
if (i%2==0)
k='*';
else
k='#';
for (int j=1;j<=a;j++)
{
printf("%c",k);
if(k=='#')
k='*';
else
k='#';
}
printf("n");
}
}

Leave a Reply

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

More posts. You may also be interested in.