Computersnyou

C Programming–How to Output Pascal Triangle using 11’s Multiple

Posted on  6/11/2012
Hi Guys, this is a program to output a Pascal Triangle using 11’s Multiple . Now, along with my tutorials on various topics, I will also provide you with  programs as well .

# include
# include

long int power(long int base,long int expo)
{
     long int i,value=1;
    for(i=0;i
     {
          value=base*value;


     }

     return value;
}

int main()
{

long int n,t,i,l,p,digit,p1,expo,rnum=0,digit1;
l=0;
printf(“Enter the Height of Your Pascal Triangle:”);
scanf(“%ld”,&n;);

for(t=1;t<=n;t++)
{
      for(i=t;i
           printf(” “);

       expo=t-1;

       if(l==0)
       {
             p=1;
             printf(“%ld”,p);
        }

        else        {
               p=11*p;
               p1=p;
               while(p1>0)
               {
                    digit=p1%10;
                    rnum=rnum+digit*power(10,expo);
                    p1=p1/10;
                    expo–;
                 }

                 while(rnum>0)
                 {
                      digit1=rnum%10;
                      printf(“%ld “,digit1);
                      rnum=rnum/10;
                  }
            
             }

            l++;
            printf(“n”);

      }
    return 0;
}

Output
Pascal
If you have any query then do leave us a comment.Thanks!!!


  • Home
  • About