write a program that prints a pascal triangle based on the
user input(like how many stages) in an efficient time and
optimized code?

Answer Posted / abhinav

call this recursive routine:

void pascal(int n)
{
if(n==1) {
printf("%d \n", n);
return;
}
pascal(n-1);
int i;
for(i=1;i<=n; i++)
printf("%d ",i);
for(i=n-1;i>=1; i--)
printf("%d ",i);
printf("\n");
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the function of volatile in c language?

872


A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM

1902


Why c is known as a mother language?

836


What are the preprocessor categories?

818


Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)

6256


find out largest elemant of diagonalmatrix

1868


Do you know the use of 'auto' keyword?

855


List some of the dynamic data structures in C?

999


write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.

1796


How to write c functions that modify head pointer of a linked list?

727


What is file in c language?

773


Explain function?

857


What is the size of enum in c?

833


What is a good data structure to use for storing lines of text?

818


What are dangling pointers in c?

827