my code is printing squares that are build from + and -. I need to make it run itself all over untill it reaches the numbers of lines inserted by the user. after the first square I can't figure out how to make it double itself again... thats my code so far
Code:
#include <stdio.h>
#define printStart printf("Please enter the width of your square, the max num of chars per line, and the max num of lines:\n")
#define printTchau printf("Good Bye!\n")
#define printMinus printf("-")
#define printPlus printf("+")
#define printSpecialFrame printf("@")
#define printNormalFrame printf("#")
#define printNewLine printf("\n")
int main(){
//write your code here
int width,length,numline;//width- size of a square,length- the max number of chars per line,numline-number of lines
int i,j,k,n=0,c=0,z;
do
{
printStart;
scanf("%d%d%d", &width,&length,&numline);
}
while((width<=0)||(length<=0)||(numline<=0));
for (i=0; i<width ;i++)
{
while (c<length)
{
for (j=0; (j<width-i); j++)
{
printPlus;
c++;
if (c>=length)
break;
}
for (k=j;k<width+i; k++)
{
if (c>=length)
break;
printMinus;
c++;
if (c>=length)
break;
}
}
printNewLine;
c=0, n=0, k=0;
}
printTchau;
//end of code
return 0;
}
if any one has any ideas i'll be happy to hear. thx.
btw I'm only allowed to use these functions: IF, IF ELSE, CONTINUE, BREAK, FOR, WHILE, DO WHILE.