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

How do you write a program which produces its own source code as its output?

4 Answers  


count the numbers between 100 and 300, that star with 2 and ends with 2

5 Answers   Mind Tree,


which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above

0 Answers  


what is the stackpointer

2 Answers  


Hi can anyone tell what is a start up code?

0 Answers   CTS,






Can a pointer be null?

0 Answers  


Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

0 Answers  


Write a program to swap two numbers without using third variable?

0 Answers  


Can you assign a different address to an array tag?

0 Answers  


explain what is fifo?

0 Answers  


Given a string write a program to print all alphabetical characters in the order of their occurance first,followed by the sum of the numeric characters then followed by the special characters in the order of their occurance.

1 Answers   College School Exams Tests, Wipro,


Explain how do you sort filenames in a directory?

0 Answers  


Categories