I would like to ask for help.

I have to program Pascal triangle in C so it printout any off the lines/rows that i chose.

Here is a pic off the triangle:

https://kurzy.kpi.fe...ages/pascal.png

For example i need the numbers from the forth line from the top saved to an array with value 1,3,3,1 in this example.

Any ideas ? Bcs i have tried already few things and i've deleted them all bcs they haven't worked as expected.

Ty for help.

# Need a help with a Pascal triangle

Page 1 of 1## 8 Replies - 296 Views - Last Post: 05 November 2019 - 01:59 PM

##
**Replies To:** Need a help with a Pascal triangle

### #2

## Re: Need a help with a Pascal triangle

Posted 05 November 2019 - 10:58 AM

What have you tried, thought about, or considered?

### #3

## Re: Need a help with a Pascal triangle

Posted 05 November 2019 - 11:03 AM

This is my last attempt that i haven't deleted yet

long sum_squared(const int line){ int a; while(line>0){ int n = line ,k; k=a++; printf("%d,",binomialCoeff(n,k)); } } int binomialCoeff(int n, int k){ if (k==0 || k==n){ return 1; } return binomialCoeff(n-1, k-1) + binomialCoeff(n-1, k); }

### #4

## Re: Need a help with a Pascal triangle

Posted 05 November 2019 - 11:47 AM

Super. Now what isn't working so hot in that? The numbers? The spacing?

### #5

## Re: Need a help with a Pascal triangle

Posted 05 November 2019 - 12:12 PM

The part of the code that i sended is working proberly.

But i need exponenciate all the numbers in the line/row and then add them up to get one result.

And that part is not working very hot thats the part that i keep deleting bcs i dont know how to implement it into my code properly.Any idea how can i do it ?

For example i need to do this but i dont know how.

1^2+4^2+6^2+4^2+1^2=1+16+36+16+1=70

But i need exponenciate all the numbers in the line/row and then add them up to get one result.

And that part is not working very hot thats the part that i keep deleting bcs i dont know how to implement it into my code properly.Any idea how can i do it ?

For example i need to do this but i dont know how.

1^2+4^2+6^2+4^2+1^2=1+16+36+16+1=70

### #6

## Re: Need a help with a Pascal triangle

Posted 05 November 2019 - 01:16 PM

I think you yoinked the wrong chunk of code.

Try this link for breaking down the math.

https://www.geeksfor...ascal-triangle/

Try this link for breaking down the math.

https://www.geeksfor...ascal-triangle/

### #7

## Re: Need a help with a Pascal triangle

Posted 05 November 2019 - 01:39 PM

I've already visited this site but i couldn't implement any of those things to my code or at last i dont know how to be more precise.

### #8

## Re: Need a help with a Pascal triangle

Posted 05 November 2019 - 01:41 PM

Okay what's tripping you up with their example? The looping or being not recursive?

### #9

## Re: Need a help with a Pascal triangle

Posted 05 November 2019 - 01:59 PM

I dont have a problem with writing out the numbers from the line/row, i have problem working with the values from this line i need to adjust those values with help of the math operations like sum,exp aso. but i dont know how to work with them properly.

Page 1 of 1