answersLogoWhite

0

Write a C program to create a pascal triangle?

Updated: 8/18/2019
User Avatar

Wiki User

12y ago

Best Answer

#include<stdio.h>

int main(){

int line,i,j,k;

printf("Enter the no. of lines");

scanf("%d",&line);

for(i=1;i<=line;i++){

for(j=1;j<=line-i;j++)

printf(" ");

for(k=1;k<i;k++)

printf("%d",k);

for(k=i;k>=1;k--)

printf("%d",k);

printf("\n");

}

return 0;

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a C program to create a pascal triangle?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a pascal program that compute an area of a triangle?

{A program to compute the area of a triangle} {by Ogboin W. Meshach} Var; b,h:real; BEGIN Writeln('Triangle'); Write('Base: '); Readln(base); Write('Height: '); Readln(height); area:=0.5*base*height; Writeln('Area: ', area :0:2); End.


Write a program to create a maze?

this is to write or create


How do you create pascal's triangle?

1 1 11 2 11 3 3 11 4 6 4 11 5 10 10 5 1...Simply write the triangle below:11 1Then write 1 on the ends and add the two values above the position you're in to get the next triangle.


How do you know if odd or even in turbo pascal program?

if n MOD 2 == 0 THEN Write ("Even");


Write a program in qbasic to make a hut using print statemant?

a triangle then a square :)


Write a program in pascal that declares two integers and gives there sum?

This is not a question so you do not need to use a question mark at the end of your sentence.


How can you start the program 'read in the lengths of the sides of a triangle and determine whether the triangle is an isosceles triangle two sides are equal an equilateral triangle three sides are'?

This would depend on what programming language you wanted to write it in. For example, in Pascal, the code might look like this: Program Isosceles; Var A, B, C : Real; Begin WriteLn('Input side A.'); ReadLn(A); WriteLn('Input side B.'); ReadLn(B); WriteLn('Input side C.'); ReadLn(C); If A = B Then Begin If B = C Then Begin WriteLn('This triangle is equilateral.'); End Else Begin WriteLn('This triangle is isosceles.'); And so on.


Write a program that input a positive integer and prints a triangle using for loop?

write a program that reads in the size of the side of square and then pints a hollow square of that size out of asterisks and blanks?


Write a program in C to create a Circular Linked list?

#include&lt;iostream.h&gt;


How To write a java program to create three tier applications using servlets?

barsanabegam


How do you write a qbasic program to find area and circumerence of a circle?

Write a program that calculates the area of a triangle in QBASIC


What are the advantages of turbo pascal?

it would help you logically.. and would simply introduce to you what is programming.. and about coding.. as having knowledge about this turbo pascal.. it is like studying first the logic needed in coding... ^^. Well, this question implies two things. First, the programming language Pascal is good because it is simple and easy to learn, compared to other languages e.g. C or Java. The code written in Pascal is also easy to read. There is less bugs (mistakes) when we write programs in Pascal, again compared to C. Second, the Turbo Pascal (software package) is a good environment for us to conveniently write Pascal programs. There are shortcut keys to compile and run the program. There are tools for debugging (correcting mistakes) in our code, too.