# How To Draw Square, Logenze

Here is my solution. I used here Visual Studio 2010.

```// Burhan Ayan
Development Enviorement : Microsoft Visual Studio 2010 Ultimate
// About : How to draw square, empty square and logenze and circle
// Definition : I used for loops and thought as they're all matrix
// 1st row and 1st column i and j equal one
// 2nd row and 1st column i = 2, j = 1 such as..
// (It depends on what you use for the 1st for loop
// and the second one) Alright let''s deep into codes.
// It''ll be much clearer later.
#include
#include
// this is for system("pause") not to close
// when the code ends
void square(int); //the parameter of square function
void emptySquare(int); //the parameter of empty square function
void logenze(int); //the parameter of logenze function
void circle(int); //the parameter of circle function
int main(){
int cases = 0, /* I initialized this because I preffer the menu
style which comes repeatedly until I enter the
number of 5. */
a; /*This is the variable we use for taking an
integer from user*/
while(cases!=5) // Repeats till it gets the integer of 5
{ //Here is the view of menu style
printf("1-Draw a square ");
printf("2-Draw a empty square ");
printf("3-Draw a logenze ");
printf("4-Draw a circle");
printf("5-Close ");
printf("Enter the number to select: ");
scanf("%d",&cases);
switch(cases){ /* I use this because switch case
structure makes codes more systematic*/
case 1:
printf("Enter the dimension the square :");
scanf("%d",&a);
square(a); /* Calls the square function we wrote at
the beginning as parameter*/
break;
case 2:
printf("Enter the dimension of the empty square :");
scanf("%d",&a);
emptySquare(a);/* Calls the empty square function*/
break;
case 3:
printf("Enter the dimension of logenze :");
scanf("%d",&a);
logenze(a);/* Calls the logenze function*/
break;
case 4:
scanf("%d",&a);
circle(a);/* Calls the circle function*/
break;
default:
printf("Enter a number between 1 and 5\n");/*If the
user enters an inappropriate entry, it displays
this message*/
break;
printf("1-Draw a square ");
printf("\n2-Draw a empty square ");
printf("\n3-Draw a logenze ");
printf("\n4-Draw a circle");
printf("\n5-Close \n");
printf("Enter the number to select: ");
}
}
system("pause");
return 0;
}
void square(int a) // Square function
{
int i,j; //Think about i and j as rows and columns
for(i=1;i<=a;i++)
{
for(j=1;j<=a;j++)
{
printf("*");
}
printf("\n");
}
printf("\n\n");
}
void emptySquare(int a) // Empty square function
{
int i,j;//Think about i and j as rows and columns
for(i=1;i<=a;i++)
{
for(j=1;j<=a;j++)
{
if(j==1 || i==1 || j==a || i==a)
printf("*");
else if(j!=1 && j!=a && i!=1 && i!=a)
printf(" ");
}
printf("\n");
}
void logenze(int a) // Logenze function
{ /*This part of code the hardest part for me
I drew a matrix then gave i and js,
to generate a formula for it. Perhaps you'll
find an easier formula for this.*/
int i,j;//Think about i and j as rows and columns
for(i = 1; i < a; i++) {//This is the first half of logenze
for(j = 1; j if((j (i + a - 1)))
printf(" ");
else
printf("*");
printf("\n");
for(i = a; i >= 1; i--){/*The second half of logenze
It's mirror of the first half*/
for(j = 1; j if((j (i + a-1)))
printf(" ");
else
printf("*");
}
printf("\n");
}
}
void circle(int a) // Circle function
{
int i,j;//Think about i and j as rows and columns
for(i=-a;i is because i gave the a variable as
{
for(j=-a;j<=a;j++)
{
if(i*i+j*j==a*a || i*i+j*j printf("*");
else
printf(" ");
}
printf("\n");
} /* I could have done a circle(empty inside) but it seemed
me so weird. That''s why I encode it like this.*/
}```    Please, comment if you have another idea for them or if I have a mistake . I hope this is of service to you. Thanks.’