Vikram

Vikram

  • NA
  • 10
  • 3k

How to make pascal triangle border only

Aug 25 2015 8:20 AM
 I need like this...Please guide me how to make it.
                  *
               *     *
           *             *
        *                    *
   *     *      *      *     *

Answers (3)

1
Nilesh Jadav

Nilesh Jadav

  • 0
  • 23.1k
  • 15.4m
Aug 25 2015 9:39 AM
hey there!
 
 
Well this is the basic code for making this triangle :
 
int main()
{
cout<<"\"Hollow Triangle Shape\"\n\n";
int z=1;

for (int i=0; i<7; i++)
{
for (int j=7; j>i; j--)
{
cout<<" "; // displaying space here
}
cout<<"*"; // displaying asterisk here

if (i!=0)
{
for (int k=1; k<=z; k++)
{
cout<<" ";
}
cout<<"*";
z+=2;
}
cout<<endl; // endl is for new line
}

for (int i=0; i<=z+1; i++)
{
cout<<"*";
}

return 0;
}
 
I can't help you much as i dont have my PC right not ,but this is the basic step to make that out.
 
 
 
IN C++:
 
 
int main() {
//Declaring the variables.
int rows, position;
//Prompts user to enter number of rows.
printf("Enter the number of rows in the triangle: ");
scanf("%d", &rows);
//Prints the first row of the triangle.
for (position = 1; position <= rows-1; position++)
printf(" ");
printf("*\n");
//Prints the middle part of the triangle.
//Prints the last row of the triangle.
for (position = 1; position <= rows*2-1; position++)
printf("*");
return 0;
 
 
 
 
 
Accepted Answer
0
Nilesh Jadav

Nilesh Jadav

  • 0
  • 23.1k
  • 15.4m
Aug 26 2015 2:22 AM
Thank you so much !
0
Vikram

Vikram

  • 0
  • 10
  • 3k
Aug 26 2015 2:04 AM
thank u NILESH JADAV for guiding this concept