![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: pascals triangle |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |
| |||
| Code: #include<stdio.h>
#include<conio.h>
#define p printf
void main()
{
int b,m,c;
clrscr();
p("\nHow many lines do you want?: ");
scanf("%d",&b);
p("\n\n\n\n");
for (m=0;m<b;m++)
{
p("\t\t\t");
int t=1;
for (c=m;c>=0;c--)
{
p("%4d",t);
t=t*c/(m-c+1);
}
p("\n\n");
}
getch();
} Last edited by TeraTask : 11-18-2008 at 01:12 PM. Reason: Added code tags |
| |||
| Yes it works fine but it looks like a half triangle like this.. 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 i want the pascal triangle to look like a whole triangle..thanks.. Last edited by centro13 : 09-02-2008 at 09:14 PM. |
![]() |
| Thread Tools | |
| Display Modes | |
| |