Programming Language C++. I'm trying to code a program that print a Star(*) Triangle after taking input of any number from user and i'm successfully programmed that but now i want to program same but with some changes means now i want that program print triangle like this.
*
**
* *
* *
* *
* *
* *
* *
* *
*********
but i facing an unknown issue and program will print Star(*) triangle like this.
*
**
***
**
**
**
**
********
Help me or Suggest me anything that can solve this.
//Program to Print Star(*) Triangle.
#include <iostream>
using namespace std;
int main()
{
int number, i,j;
cout << "Enter the Number :";
cin >> number;
for (i=1; i<=number; i++)
{
for (j=1; j<=i; j++)
{
if (j==1 || j==i || i==number)
{
cout << "*";
}
else
{
cout << "";
}
}
cout << endl;
}
system("pause");
return 0;
}
I want an output like this.
*
**
* *
* *
* *
* *
* *
* *
* *
* *
* *
***********
Aucun commentaire:
Enregistrer un commentaire