Posted by: Sourav | September 25, 2015

A new approach to solve Pascal’s triangle for me,Sourav Bhattacharya,Teacher


#include<stdio.h>
#include<math.h>
void main()
{
/*
1
11
121
1331
14641
*/
int i;
int j;
long k,l=0;
int len=0;
long temp;
char arr[100]=””;
for(i=0;i<7;i++)
{
for(j=6;j>i;j–)
{
printf(” “);
}
k=(long) pow(11,i);
//printf(“k is %ld\n”,k);
sprintf(arr,”%ld”,k);
//printf(“%c\n”,arr[0]);
while(1)
{
if(arr[l]!=’\0′)
{
len++;
l++;
}
else
break;

}
j=0;
while(j<len)
{
printf(“%c “,arr[j]);
j++;
}
printf(“\n”);
memset(&arr[0], 0, sizeof(arr));
l=0;len=0;
}

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: