C program to print pascal's triangle using arrays for loop write code

itstudentjunction

C program to print pascal's triangle using arrays for loop write code


Write a C program to implement pascal's triangle using arrays for loop,


write a C Program to print pascal's triangle using for loop / Write a C program for pascal's triangle using arrays / write a C Program to print pascal's triangle using arrays

#include<stdio.h>
#include<conio.h>
void main(){
int a[15][15],i,j,rows,num=25,k;
printf("Implement Pascal's Triangle:");
printf("\n enter the number of rows for pascal's triangle:");
scanf("%d",&rows);
for(i=0;i<rows;i++){
for(k=num-2*i;k>=0;k--)
printf(" ");
for(j=0;j<=i;j++){
if(j==0||i==j){
a[i][j]=1;
}
else{
a[i][j]=a[i-1][j-1]+a[i-1][j];
}
printf("%4d",a[i][j]);
}
printf("\n");
}
getch();
}

OUTPUT:

Implement Pascal's Triangle:

enter the number of rows for pascal's triangle:3

       1
      1 1
     1 2 1


list of c programs



Most popular programs


write a program to find factorial using c
WAP to Calculate Simple Interest
Check for even / odd
perfect or not
sum of two matrices
display numbers pyramid
show amicable pairs
factors of a number using for loop, while
prime factors of integer using functions recursion
convert to uppercase
generater prime numbers using for loop
Write a C program to print pascal's Triangle using arrays for loop
check reverse string arrays
find string length strlen
Calculate compound Interest
Write a program to find armstrong number or not
print prime numbers using while
solve towers of hanoi
Display Floyd’s Triangle
reverse string using pointers
write a program to find a number is prime or not
Show revers number
calculate LCM concatinate strings using arrays
write a program to find palindrome or not
WAP to print sum of Digits
display transpose matrix
show lower triangle
multipiy two matrices
write a program to calculate GCD
strong number or not
check substring in c
string length using arrays
string length using pointers
convert to lowercase
WAP to find factors
count no.of digits
show inverse of matrix
show reverse string strrev
write a program to display upper triangle
concatinate strings strCat
convert to lowercase
check for palindrome string
substring position in a string
compare two strings arrays
compare strings strcmp
find roots of quadriaic expression
show fibonacci numbers
factorial using recurrsion
sum of factorial series
convert decimal to binary
Write a program to print armstrong numbers

decimal to octal
compare strings pointers
decimal to hexadecimal
sum of n numbers
average of n
largest of two
largest of n

strong numbers
perfect numbers using for loop


C Programs Data structures Programs in c Data structures Programs in c++ Unix commands Linux commands C++ programs Data structures Algorithms Java Programs UML Diagrams Assembly Language Programs DBMS j2ee programming