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



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

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

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

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

Post New Answer

More C Interview Questions

What are different types of variables in c?

0 Answers  


Write a code to determine the total number of stops an elevator would take to serve N number of people.

0 Answers   Expedia,


What is the process of writing the null pointer?

0 Answers  


write a c/c++ program that takes a 5 digit number and calculates 2 power that number and prints it?

4 Answers  


How can I sort a linked list?

0 Answers  


what is the basis for selection of arrays or pointers as data structure in a program

0 Answers   TCS,


how many times of error occur in C

11 Answers  


implement general tree using link list

1 Answers   Wipro,


Explain the difference between the local variable and global variable in c?

0 Answers  


praagnovation

0 Answers  


How can I rethow can I return a sequence of random numbers which dont repeat at all?

0 Answers  


Who had beaten up hooligan "CHAKULI" in his early college days?

1 Answers  


Categories