Dec 16, 2018, 02:15 AM

News:

Choose a design and let our professionals help you build a successful website   - ITAcumens


Calculate the Pascal triangle

Started by OmMuruga, Jan 15, 2009, 04:25 AM

previous topic - next topic
Go Down

OmMuruga

To calculate the Pascals Triangle for given number .

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10];
int i,j,c,n;
clrscr();
printf("Enter how many lines do you want");
scanf("%d",&n);
a[1][1]=1;
printf("%5d",a[1][1]);
a[2][1]=1;a[2][2]=2;a[2][3]=1;
printf("%d %d %d",a[2][1],a[2][2],a[2][3]);
for(i=3;i<=n;i++)
  {
   a[1]=1;
   printf("%d",a[1]);
   j=2;c=3;
   while(j<=i)
   {
    a[j]=a[i-1][c-1]+a[i-1][c-2];
    printf("%5d",a[j]);
    c=c+1;
    j=j+1;
   }
a[j]=1;
printf("%d",a[j]);
}
}
:acumen

nandagopal



This code works perfectly but little explanation needed !!!!




pradeep prem

this is easy program to solve this easy with loop

Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:
Verification:
Please leave this box empty:

Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

shortcuts: alt+s submit/post or alt+p preview
IT Acumens | GinGly :: SMS Backup | Acumen :: Discussion Board | AshokPillar :: Hosting | CineBuzz :: Latest Cinema News | My Kids Diary :: Capture your kids magical moment
Copyright 2005 - 2017 :: IT Acumens :: All Rights Reserved.
ITAcumens Forum with 2 lakhs post running for 10 years - Powered by HostGator Dedicated Server