CODE
#include <stdio.h>
#include <conio.h>
void main ()
{
clrscr ();
int a, b, star; //integor declaration
//starting point of upper diamond shape loop
for (a = 1; a <=7; a+=2)
{
gotoxy (36, a+12);
for (b = (10 - a) /2; b >0; b--)
{
printf (" ");
}
for (star = 1; star <= a; star++)
{
printf ("*");
}
printf ("\n");
}
//ending point of upper diamond shape loop
//staring point of bottom diamond shape loop
for (a = 5; a >= 0; a -= 2)
{
gotoxy (b, a-12);
for (b = (10 - a) /2; b > 0; b--)
{
printf (" ");
}
for (star = 1; star <= a; star++)
{
printf("*");
}
printf ("\n");
}
getch ();
}
//ending point of bottom diamond shape loop
The upper part of the diamond is giving me accurate result, it display in center from top to bottom and also left to right.
But the bottom part of the diamond shape is not giving me accurate result.
I think there is a problem of gotoxy statement in the bottom diamond shape program.
So guide me to point out this problem.
Thanx.