0
The question says the following:
Write a program that reads the side of a square and then print the square with asterisks. Your program should work with squares of all sizes between 1 and 20. For example, if your program reads a size 4, it should print out
**** **** **** ****
Even that part of the book I’m reading didn’t mention for
or do ... while
, only while
. So I made this code. I’m starting now but I think it should have worked.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int contador=1, linha=1, valor=0;
printf("entre com o valor:\n\n");
scanf("%d", &valor);
while (contador<=valor && linha<=valor) {
printf("*");
contador++;
}
printf("\n");
contador = 1;
linha++;
return 0;
}
I don’t understand if I put at the end of the command while
which accountant should go back to 1
, the loop should not start again?
If you could tell me what I should study to fix this code, I’d appreciate it.
obg for telling where I went wrong. after seeing the problem it seemed very obvious kkk. obg
– William Garcia