Pascal triangle

i have written the right code and logic but still my test cases are failing.
here is the code,

#include
using namespace std;

int fact(int n)
{
int f=1;
while(n!=0)
{
f=f*n;
n–;
}
return f;
}

int ncr(int n,int r)
{
return fact(n)/(fact®*fact(n-r));
}

int main() {
int n;
cin>>n;

for(int i=0;i<n;i++)
{
	for(int j=0;j<(n-i-1);j++)
	{
		cout<<"  ";
	}
	for(int j=0;j<=i;j++)
	{
		cout<<ncr(i,j)<<"   ";
	}
	
	cout<<endl;
}

return 0;

}

hey @sakshamarya1, i would reuqest you to share your code by using ide.codingblocks.com :smile:

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.

hello @sakshamarya1
pls check ur updated code here->

yes got it, thanks a lot