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
Describe static function with its usage?
What are the loops in c?
Is c compiled or interpreted?
What is a null pointer in c?
What is exit() function?
a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none
In a switch statement, what will happen if a break statement is omitted?
What does malloc () calloc () realloc () free () do?
how many errors in c explain deply
What are the advantages of using new operator as compared to the function malloc ()?
Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given
List some of the static data structures in C?
What is c system32 taskhostw exe?
Write a program in c to replace any vowel in a string with z?
Write a program to use switch statement.