\(\begin{array}{ccccc}*&&&&*\\&*&&*&\\&&*&&\\&*&&*&\\*&&&&*\end{array}\) 

Write a program that reads a number and displays the above pattern.


Difficulty level
This exercise is mostly suitable for students
#include<stdio.h>
#include<conio.h>

void main()
{
	int N, i, j;
	do{
		printf("Enter N: ");
		scanf("%d",&N);
	}while(N<=0);

	for(i=1; i<2*N; i++)
    	{
		for(j=1; j<2*N; j++)
            		if(j==i || (j==2*N - i))
				printf("*");
            		else
               		 	printf(" ");

        	printf("\n");
    	}

	getch();
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Hashing with a special collision function