when running the code, the while loop is re-printing the prompts asking for the user to pick an option and dimensions before printing the rectangle, when it should print the shape and then iterate through the prompts. What in the while loop would be causing those printf statements to re-print?
Code:
#include "testFile.h"
int draw_rectangle(char sym, int wid, int len){
if((wid == 0) || (len == 0)){
printf("Invalid data provided 2\n");
return 0;
}else{
int i;
int j;
for(i = 1; i <= wid; i++){
for(j = 1; j <= len; j++){
printf("%c", sym);
}
printf("\n");
}
return 1;
}
}
int main(){
int loopTrue = 1;
char character;
int length, width;
int userOption = 4;
while(loopTrue == 1){
printf("Enter 1(rectangle), 2(triangle, 3(other), 0(quit): ");
scanf("%d", &userOption);
if(userOption >= 4){
printf("Invalid data operation 1 \n");
}else if(userOption == 0){
printf("bye bye");
loopTrue = 0;
}else if(userOption == 1){
printf("enter a character, width, and length: ");
scanf("%c %d %d", &character, &width, &length);
draw_rectangle(character, width, length);
}else if(userOption == 2){
printf("not done\n");
}else if(userOption == 3){
printf("not done\n");
}
}
return 0;
}