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.
Answer Posted / 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 View All Answers
Is register a keyword in c?
Can the size of an array be declared at runtime?
How do we make a global variable accessible across files? Explain the extern keyword?
What is the use of a static variable in c?
while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above
formula to convert 2500mmh2o into m3/hr
I need testPalindrome and removeSpace
#include
How many parameters should a function have?
in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above
What do you mean by Recursion Function?
A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.
Can the curly brackets { } be used to enclose a single line of code?
What are called c variables?
What is return type in c?
Why should I use standard library functions instead of writing my own?