Hi Friends
If we give number of rows in input we get the pascal triangle with that rows.
Ex-
Sample input
5
Sample out put
Program
CLICK HERE TO RUN THE PROGRAM
in the above program we will learn about how to print pascal triangle when we enter the number n which indicates the row size. and then we write the code to print stars . in this program we use the concept of nested loops to print the stars in order. in the for loop we use printf("\n"); that separate the rows of the pascal triangle. i hope you enjoy to learn on our site for more programs please click the follow button below.
we can also write the program to print pascal triangle with numbers. so that we just change a simple code that is in the for loop in printf we replace the code to print the j so that we get the pascal triangle like given below.
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
or we can also change this output by just changing the for loop of j we can print the i value so that we get the output given below.
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
For learn with me
https://docs.google.com/spreadsheets/d/1-n_JYxo7gxKBr0D852KrqCoAYpXgRpbC/edit#gid=316176436
ReplyDelete