#include <stdio.h>

// This program will print square and triangular “shapes” using asterisks. It will prompt
// the user to select a shape by entering "1" for square or "2" for triangle. 
// It will then prompt for the size followed by prompting for “not filled” (0) 
// or “filled” (1). After printing the shape, the program will loop back and
// prompt again for another. "Illegal" shape selections will cause the program to exit.

int main() {
	int i, j;
	int shape, size, fill, width;
	
	while (1) {
		printf("Enter shape (1) Square, (2) Triangle, (other) Quit: ");		// Prompt user
		scanf("%d", &shape);
		if (shape != 1 && shape !=2) return 0;
		printf("Enter size: ");
		scanf("%d", &size);
		printf("Enter (0) No fill, (1) Fill: ");
		scanf("%d", &fill);
		printf("\n\n");
		
		for (i=0; i<size; i++) {										// Print the shape
			width = shape==1 ? size : i+1;
			for (j=0; j < width; j++) {
				printf("%c", (j==0 || j==width-1 || i==0 || i==size-1 || fill ==1) ? '*' : ' ');
			}
			printf("\n");
		}
		printf("\n");
	}
}

