Test cases not passing (Pascal Triagle problem)

Here is my code for pascal triangle problem:

#include<bits/stdc++.h>
using namespace std;
int main(){

int n ;
for (int i = 0; i < INT_MAX ; i++)
{
cin >> n ;
if (n <= 10){
break;
}
else
{
cout << “Enter no less than 10” << endl ;
}

}


for (int i = 0; i < n; i++)
{
    
    for (int space = n-1 ; space > i; space --)
    {
        cout<<" ";
    }


    int c  = 1 ;
    cout << "1 " ;
    
    for ( int j = 1; j <= i ; j++)
    {
    
        c = c*(i-j+1 )/(j);
        cout <<c<< " ";
    }

    cout << endl;
}

}

Check now, keep spaces as in output format. Also don’t print anything extra.


Take this code for reference

Check your inbox. Or you can reply here too .

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.

Can you please tell the problem in my code :

Here is the updated code :

#include<bits/stdc++.h>
using namespace std;
int main(){

int n ;
cin>>n;

if (n<=10){
for (int i = 0; i < n; i++)
{

    for (int space = n-1 ; space > i; space --)
    {
        cout<<" ";
    }


    int c  = 1 ;
    cout << "1 " ;
    
    for ( int j = 1; j <= i ; j++)
    {
    
        c = c*(i-j+1 )/(j);
        cout <<c<< " ";
    }

    cout << endl;
}

}
}

In my editor I am getting the correct results(output) but while submitting none of the test case is passing

Okay don’t ask a new doubt, your this code is absolutely correct. Just issue with the output format.

Make it as

for (int i = 0; i < n; i++)
{
cout<<“ “;
//remaining program same as you have done. Do this all your test cases will get passed

Hello @ishuvivek279 you have raised the doubt again.
though another TA has already told you what you are doing wrong.
still if you have doubt :
you can see this code:
i have corrected your code:


if you have any doubt you can ask here:
Happy Learning!!

ok thanks a lot, my doubt is solved now

@ishuvivek279 if you feel that your doubt is solved you can mark this as resolved.
Happy Learning!!

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.