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 / vamsi krishna
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,n;
clrscr();
printf("enter the highest power");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=0;j<(n-i);j++)
printf(" ");
for(j=0;j<=i;j++)
printf("%d ",c(i,j));
printf("\n");
}
getch();
}
c(int i,int j)
{
int k,N=1,D=1;
if(i==0 || j==0)
return(1);
for(k=0;k<j;k++)
{
N=N*(i-k);
D=D*(j-k);
}
return(N/D);
}
Is This Answer Correct ? | 4 Yes | 2 No |
Post New Answer View All Answers
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
Why we use stdio h in c?
What should malloc() do?
the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset
What do you understand by friend-functions? How are they used?
What is the difference between a string and an array?
Why does not c have an exponentiation operator?
What is the symbol indicated the c-preprocessor?
What is the use of the function in c?
What is the -> in c?
Why is c called a structured programming language?
please give me some tips for the placement in the TCS.
Is fortran faster than c?
Can we use any name in place of argv and argc as command line arguments?