Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

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 ..

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 ..

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

More C Interview Questions

What are the valid places to have keyword “break”?

7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.

Is both getch() and getchar() functions are similar? if it is similar means why these two functions are used for same usage? if it is not similar means what is the difference?

In the following control structure which is faster? 1.Switch 2.If-else and which consumes more memory?

Without using main fn and semicolon,print remainder for a given number in C language

write a program for even numbers?

What is the general form of #line preprocessor?

print the pattern 1 2 4 3 6 9 4 8 12 16 5 10 15 20 25 if n=5

while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above

How to throw some light on the b tree?

code for replace tabs with equivalent number of blanks

Categories