pascal triangle program
Answers were Sorted based on User's Feedback
Answer / azad sable, chiplun
void main()
{
int i,j,k,t,f1,f2,f3,z,sp;
sp=20;
clrscr();
for(i=0;i<=4;i++)
{
for(k=0;k<sp-1;k++)
printf("");
sp=0;
for(j=0;j<=i;j++)
{
f1=f2=f3=1;
t=i;
while(t!=0)
{
f1=f1*t;
t--;
}
t=j;
while(t!=0)
{
f2=f2*t;
t--;
}
t=i-j;
while(t!=0)
{
f3=f3*t;
t--;
}
z=f1/(f2*f3);
printf("%4d",z);
}
printf("\n");
}
getch():
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sevak.yatrik777
with Ada.Integer_Text_Io; use Ada.Integer_Text_Io;
with Ada.Text_Io; use Ada.Text_Io;
procedure Pascals_Triangle is
type Row is array(Positive range <>) of Integer;
type Row_Access is access Row;
type Triangle is array(Positive range <>) of Row_Access;
function General_Triangle(Depth : Positive) return
Triangle is
Result : Triangle(1..Depth);
begin
for I in Result'range loop
Result(I) := new Row(1..I);
for J in 1..I loop
if J = Result(I)'First or else J =
Result(I)'Last then
Result(I)(J) := 1;
else
Result(I)(J) := Result(I - 1)(J - 1) +
Result(I - 1)(J);
end if;
end loop;
end loop;
return Result;
end General_Triangle;
procedure Print(Item : Triangle) is
begin
for I in Item'range loop
for J in 1..I loop
Put(Item => Item(I)(J), Width => 3);
end loop;
New_Line;
end loop;
end Print;
begin
Print(General_Triangle(7));
end Pascals_Triangle;
| Is This Answer Correct ? | 0 Yes | 0 No |
#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b); }
write a program to fined second smallest and largest element in a given series of elements (without sorting)
Explain what is the stack?
why ordinary variable store the later value not the initial
What are the difference between a free-standing and a hosted environment?
write a C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.
what is the output of the following code? main() { int I; I=0x10+010+10; printf("x=%x",I); } give detailed reason
How are variables declared in c?
Can we initialize extern variable in c?
Where local variables are stored in c?
1.find the second maximum in an array? 2.how do you create hash table in c? 3.what is hash collision
Write an algorithm for a program that receives an integer as input and outputs the product of of its digits. E.g. 1234 = 24, 705 = 0