Write a C program to get the desired output.


1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
.
.
.
1 n..............n 1
Note: n is a positive integer entered by the user.

Answers were Sorted based on User's Feedback



Write a C program to get the desired output. 1 ..

Answer / sandip pal

#include<stdio.h>
#include<conio.h>
int ncr(int,int);
int fact(int);
void main()
{
int i,j;
clrscr();
for(i=0;i<=5;i++)
{
printf("\n\n");
for(j=0;j<=5-i;j++)
printf(" ");
for(j=0;j<=i;j++)
printf(" %2d ",ncr(i,j));
}
getch();
}
int ncr(int n,int r)
{
int f;
f=fact(n)/(fact(n-r)*fact(r));
return f;
}
int fact(int n)
{
if(n==0)
return 1;
else
n=n*fact(n-1);
return n;
}

Is This Answer Correct ?    3 Yes 0 No

Write a C program to get the desired output. 1 ..

Answer / ch.mahathi

could anyone please assist me in getting the output in the following way?

For example, if you have entered a pin number like 532211 as the input to the program , then the output should be like this



(5)+(5+3)+(5+3+2)+(5+3+2+1)+(5+3+2+2+1)+(5+3+2+2+1+1)

Is This Answer Correct ?    0 Yes 0 No

Write a C program to get the desired output. 1 ..

Answer / tknowledge05

The above guest is me .. ookk....
by the time i solved and executing i was logged out and when i posted the answer it considered guest.......

Is This Answer Correct ?    1 Yes 2 No

Write a C program to get the desired output. 1 ..

Answer / guest

#include<conio.h>
#include<stdio.h>
void main()
{
int a[10],b[10];
int c=1,n=5;
a[0]=0;a[1]=1;a[2]=0;
b[0]=0;
printf("Enter no. of rows to print ");
scanf("%d",&n);
for(int i=0;i<n;i++)
{
for(int j=n-2;j<0;j++)
printf(" ");
c++;
for(int k=0;k<c;k++)
{
b[k+1]=a[k]+a[k+1];
}
b[c]=0;
for(int k=1;k<=i+1;k++)
{
printf("%d ",a[k]);
}
printf("\n");
for(int k=0;k<i+3;k++)
a[k]=b[k];
}
getch();
}


Is This Answer Correct ?    4 Yes 6 No

Post New Answer

More C Interview Questions

Diff: between this 2 classes in terms of memory class A { int i; char c; double d; }; class A { double d; int i; char c; }; How it is calculating?

1 Answers   HCL,


6)What would be the output? main() { int u=1,v=3; pf("%d%d",u,v); funct1(&u,&v); pf("%d%d\n",u,v); } void funct1(int *pu, int *pv) { *pu=0; *pv=0; return; } a)1 3 1 3 b)1 3 1 1 c)1 3 0 0 d)1 1 1 1 e) 3 1 3 1

4 Answers  


What are dangling pointers? How are dangling pointers different from memory leaks?

1 Answers  


what does ‘#include’ mean?

1 Answers   TCS,


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

0 Answers  






What is formal argument?

0 Answers  


Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?

0 Answers   MNC,


Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?

0 Answers  


Why cant I open a file by its explicit path?

0 Answers  


write a c program to accept a given integer value and print its value in words

4 Answers   Vernalis, Vernalis Systems,


What is structure padding & expalain wid example what is bit wise structure?

1 Answers  


what is meant by the "equivalence of pointers and arrays" in C?

3 Answers   Satyam,


Categories