Hello Friends...
I'm writing a C program to print pattern of swastik using *. I want to set my pattern in the center of the screen. Can anyone tell me how can I do this ????
Below is the C program for swastik, but it do not print swastik in the center.

#include<stdio.h>
#include<conio.h>
void main()
{
	int i,j,n;
	clrscr();
	again:
	printf("\n Enter Value for n (odd) : ");
	scanf("%d",&n);
	if(n%2==0)
		goto again;
	clrscr();
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(j==0 && i<=(n-1)/2 || j==n-1 && i>=(n-1)/2
			|| i==0 && j>=(n-1)/2 || i==n-1 && j<=(n-1)/2
			|| i==(n-1)/2 || j==(n-1)/2)
				printf("* ");
		    else
			printf("  ");
		}
		printf("\n\n");
	}
	getch();
}

Figure out what the width of the screen is, divide that by 2, then subtract half of the shape's width that you're trying to print. Then before printing each row of the shape, add that many spaces.

Can't I use any graphics functions in my program???

Can't I use any graphics functions in my program???

I don't know, can you?

I don't know, can you?

I'm trying... not succeeded yet. please tell me if you find any other option.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.