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

Write a program that prints inverted trapezoids using the character \'@\'. The u

ID: 3850472 • Letter: W

Question

Write a program that prints inverted trapezoids using the character '@'. The user will enter the number of '@'s on the rst row and then the number of rows forming the trapezoid. For instance, an inverted trapezoid with 7 '@"s in the rst row and 3 rows forming the inverted trapezoid looks like:
@@@@@@@
   @@@@@
      @@@
No row is allowed to have less than two '@'s. You will write code to check for this.
Write a program that prompts for a positive integer and prints the factors of all integers from 1 to that input integer.

Explanation / Answer

#include <iostream>
using namespace std;

int main()
{

int i,j,k,row,col,space;

space = 1;
cout<<" Enter the values of rows and columns : ";
cin>>row>>col;

char ch = '@';
cout<<endl;

for (i = 0; i< row; i++)
{
for (j = 0; j < space; j++) //add spaces in front
cout<<" ";



for (j = 0 ; j < col; j++)
cout<<ch; //display character

col = col-2; //reduce the columns by 2 at each row
space++; //increase the space by 1 at each row in the left side
cout<<endl;
}
   return 0;
}

Output:

Enter the values of rows and columns : 3 7
@@@@@@@
@@@@@
@@@

2.

#include <iostream>
using namespace std;

int main()
{
int number, i;

cout << "Enter a positive integer: ";
cin >> number;

cout << "Factors of " << number <<": " << endl;
for(i = 1; i <= number; ++i)
{
if(number % i == 0) //if number is divisible by any i , i the factor of number
cout << i << " ";
}

return 0;
}

Output:

Enter a positive integer: 49

Factors of 49:
1 7 49

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