I am quite new to programming and I have got an assignment which I cannot move with.
So the program must take the user input, the length and width of a rectangle and then draw the rectangle using stars * based on the parameters length and width. I have to do it using for loops, more precisely one for loop inside the other.
It does not work and I am stuck with it, so please if someone would be so kind to help me, I would be thankful.
Here is what I got:
int main() {
printf("\n\n***Rectangle***");
printf("\n\n\nInsert side a: ");
scanf("%f", &sideA);
printf("\n\nInsert side b: ");
scanf("%f", &sideB);
printf("\n\nRectangle: \n\n");
for (int i = 0; i < sideA; i++) {
for (int j = 0; j < sideB; j++) {
if (i == 0 || i == sideB - 1 || j == 0 || j == sideA - 1) {
printf("*");
} else {
printf(" ");
}
printf("\n");
}
}
}
Thanks so much in advance