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

Write a program to check prime number in c programming?

0 Answers  


Why enum is used in c?

0 Answers  


How to add two numbers without using semicolon at runtime

2 Answers  


write a program to find the sum of the array elements in c language?

24 Answers   ICT, Infosys, Wipro,


void main() { //char ch; unsigned char ch; clrscr(); for(ch =0;ch<= 127; ch++) printf(" %c= %d \t ", ch, ch); } output?

4 Answers   Groupon,


how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.

0 Answers  


Can you tell me how to check whether a linked list is circular?

1 Answers  


What is the difference function call by value & function call by reference?

6 Answers  


What are different storage class specifiers in c?

0 Answers  


Explain what is the advantage of a random access file?

0 Answers  


10. Study the code: void show() main() { show(); } void show (char *s) { printf("%sn",s); } What will happen if it is compiled & run on an ANSI C Compiler? A)It will compile & nothing will be printed when it is executed B)it will compile but not link C)the compiler will generate an error D)the compiler will generate a warning

5 Answers   Accenture,


wt is d full form of c

6 Answers   TCS, Wipro,


Categories