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
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / sandeep roy
public static void main(String[] args) {
int j=11;
int s=11;
for(int i=1;i<=5;i++) {
if(i==1)
System.out.println(i);
else
{
System.out.println(s);
s=s*j;
}
}
}
Is This Answer Correct ? | 1 Yes | 0 No |
What are different types of variables in c?
Write a code to determine the total number of stops an elevator would take to serve N number of people.
What is the process of writing the null pointer?
write a c/c++ program that takes a 5 digit number and calculates 2 power that number and prints it?
How can I sort a linked list?
what is the basis for selection of arrays or pointers as data structure in a program
how many times of error occur in C
implement general tree using link list
Explain the difference between the local variable and global variable in c?
praagnovation
How can I rethow can I return a sequence of random numbers which dont repeat at all?
Who had beaten up hooligan "CHAKULI" in his early college days?