in c Where I can output an upside down star that has 5 stars

in c++. Where I can output an upside down star that has 5 stars on the first line, 3 stars in the middle line, and 1 star on the bottom with spaces like *****

                                                                                                                                                                                                                                            ***

                                                                                                                                                                                                                                             *

Solution

//Tested on Ubuntu,Linux

#include <iostream>

using namespace std;
/* Main funtion start */
int main() {
/*Variable declaration*/
int n;
/*prompt for value N*/
std::cout<<\"Please Enter the Value of N\"<<std::endl;
std::cin>>n;

/* printing star pattern 5 star,3 star, 1 star
* we are decreasing i value to 2
* inner loop will print star i number of time*/
for(int i=n-1;i>=0;i=i-2) {
   for(int j=0;j<=i;j++) {
       std::cout<<\"* \";
   }
   /* new line after star printing*/
   std::cout<<std::endl;
  
}


/*Return to os*/
return 0;
}
/*Main function End*/


/*******************output******************/

anshu@anshu:~/Desktop/chegg$ g++ starPattern.cpp
anshu@anshu:~/Desktop/chegg$ ./a.out
Please Enter the Value of N
5
* * * * *
* * *
*

Thanks a lot

in c++. Where I can output an upside down star that has 5 stars on the first line, 3 stars in the middle line, and 1 star on the bottom with spaces like ***** *

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site