Q.11 Generate the following pattern using code in any
language(c/c++/java) for n no. of rows

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

Answer Posted / balaji ganesh

main()
{
int a[20][20],i,j,n;
clrscr();
a[0][0]=1;
scanf("%d",&n,printf("enter how many rows you want:"));
for(i=0;i<n;i++)
{a[i][0]=1;a[i][i]=1;
for(j=1;j<i;j++)
a[i][j]=a[i-1][j-1]+a[i-1][j];
}
for(i=0;i<n;i++)
{printf("\n\n");
for(j=0;j<=i;j++)
printf("%d ",a[i][j]);
}
getch();
}



Is This Answer Correct ?    6 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is bubble sort in c?

625


How to declare pointer variables?

669


List the difference between a While & Do While loops?

622


What is output redirection?

678


Why is c called "mother" language?

845






What is the ANSI C Standard?

764


5 Write an Algorithm to find the maximum and minimum items in a set of ā€˜nā€™ element.

1568


What is pass by reference in functions?

309


How do c compilers work?

594


Is calloc better than malloc?

561


What does 3 periods mean in texting?

585


Are enumerations really portable?

583


What is logical error?

590


How many types of operator or there in c?

588


What is queue in c?

561