Pascal triangle issue

#include

using namespace std;

int main() {

int Number,nsp=2;

cin>>Number;

for(int row=1;row<=Number;row++)

{

	for(int spaces=1;spaces<=Number+nsp;spaces++)

	{

		cout<<" ";

	}

	if(row==1)

	{

		cout<<"1";

	}

	else

	{

		cout<<"1\t";

		int num=row-1;

		int den=1;

		int multiply=1;

		for(int column=1;column<=row-2;column++)

		{

			multiply=multiply*(num/den);

			cout<<multiply<<"\t";

			num=num-1;

			den=den+1;

		}

		cout<<"1\t";

	}

	cout<<endl;

	nsp=nsp-2;

}

}

//sir why is there an unindentation i have given only tab spaces than why?

@tejasddongare removed the spaces issue now give it as required and check your o/p for n=6 it ain’t right

1 Like

sir what was issue than?

@tejasddongare your logic for spaces was not correct

sir can i get corrected code of mine??

@tejasddongare refer this for the approach
https://www.geeksforgeeks.org/pascal-triangle/
read it and then try the code if facing issue then tell me

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.