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
What is bubble sort in c?
How to declare pointer variables?
List the difference between a While & Do While loops?
What is output redirection?
Why is c called "mother" language?
What is the ANSI C Standard?
5 Write an Algorithm to find the maximum and minimum items in a set of ānā element.
What is pass by reference in functions?
How do c compilers work?
Is calloc better than malloc?
What does 3 periods mean in texting?
Are enumerations really portable?
What is logical error?
How many types of operator or there in c?
What is queue in c?