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

There is a program we are asked to write but not really sure how. Write a progra

ID: 3629713 • Letter: T

Question

There is a program we are asked to write but not really sure how.



Write a program that prompts the user to enter a positive integer number. Use this number to draw an upside down triangle with that height, like in the following examples:

Constraints

Make sure the program checks for positive integers only, 1 or greater
If a non-negative number is entered print out: Input Error
Only use the '*' character and spaces.
Do not print out any additional output.
Example run 1:

Enter triangle height: 5
*********
*******
*****
***
*
Example run 2:

Enter triangle height: 3
*****
***
*
Example run 3:

Enter triangle height: -3
Input Error

Explanation / Answer

#include<stdio.h>

#include<conio.h>

#include<iostream>

int main()

 printf("Please enter the no. of rows");

int n;

int i,j;

scanf("%d",&n);

if(n<=0)

printf("Input  error");

else

for( i=n;i>=1;i--)

{   

 for( j=1;j<=i;j++)   

 printf("*"); 

  printf(" ");

}

}

}

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