This program draws a rectangle or square based on user input, but how do I modify it to draw a triangle based on user input?
Code:
#include <stdio.h>
void printBox(int width,int height,char style);
main()
{
int width;
int height;
char style;
printf("Enter a width\n");
scanf("%d",&width);
printf("Enter a height\n");
scanf("%d",&height);
printf("Enter a style\n");
scanf(" %c",&style);
printf("\n\n\n");
printBox(width,height,style);
printf("\n\n\n");
}
void printBox(int w,int h,char s)
{
int cntW;
int cntH;
for (cntH=0; cntH<h; cntH++)
{
for (cntW=0; cntW<w; cntW++)
{
printf("%c",s);
}
printf("\n");
}
}