Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that asks the user to enter an integer between 1 and 15. If the

ID: 3935067 • Letter: W

Question

Write a program that asks the user to enter an integer between 1 and 15. If the number entered is outside that range, your program should print out an error message and re-prompt for another number.

Once the user enters a number in the correct range, your program will print out four patterns of asterisks that look like the following. Note that the number provided by the user is equal to the height of the pattern.

This is what the output should look like. There needs to be two right triangles and two isosoceles triangles. The iso triangle needs to be filled in for one and the other needs to be unfilled.

http://tinypic.com/r/e7nq5w/9

Explanation / Answer

#include<stdio.h>
int main()
{
int n;
abc:
printf("enter n between 1 and 15 : ");
scanf("%d",&n);
if(!(n>=1&&n<=15))
{
printf(" invalid input");
goto abc;
}
printf(" ");
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
printf("*");
}
printf(" ");
}
printf(" ");
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(j>=i)printf("*");
else
printf(" ");
}
printf(" ");
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote