Chapter:

Pattern-Printing-in-C

Write a program in C to generate following pattern using unformatted input/output functions only. [2074-Ashwin][5]


    N

   eee 

  PPPPP

 aaaaaaa

LLLLLLLLL

#include
void main()
{
	char ch[]="NEPAL",space=' ',next_line='\n';
	int i,j,n=5,k;
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=n-i;j++)
		{
			putchar(space);
		}
		for (j=1;j<=2*i-1;j++)
		{
			if (i%2!=0)
			{
				putchar(ch[i-1]);
			}
			else
			{
				putchar(ch[i-1]+32);
			}
		}
		putchar(next_line);
	}
}
Show More

All Chapters

View all Chapter and number of question available From each chapter from C-programming-