The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > C / C++


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:

Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 12-04-2007, 02:38 AM
trowa0830 trowa0830 is offline
Novice
Join Date: Dec 2007
Posts: 7
iTrader: (0)
trowa0830 is on a distinguished road
can some one help me in turbo c

i need help in programming a pascal triangle in turbo using for loops.. can some one help me.. can you please send it in my email.. thanks in advance...

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 12-04-2007, 06:37 AM
siLenTz's Avatar
siLenTz siLenTz is offline
Jr. Programmer
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Posts: 87
iTrader: (0)
siLenTz will become famous soon enoughsiLenTz will become famous soon enough
Quote:
Originally Posted by trowa0830 View Post
i need help in programming a pascal triangle in turbo using for loops.. can some one help me.. can you please send it in my email.. thanks in advance...
Is it your homework?

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to siLenTz For This Useful Post:
TeraTask (12-05-2007)
  #3 (permalink)  
Old 12-04-2007, 09:38 AM
trowa0830 trowa0830 is offline
Novice
Join Date: Dec 2007
Posts: 7
iTrader: (0)
trowa0830 is on a distinguished road
it's a project.. can u help me??

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #4 (permalink)  
Old 12-04-2007, 11:26 AM
siLenTz's Avatar
siLenTz siLenTz is offline
Jr. Programmer
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Posts: 87
iTrader: (0)
siLenTz will become famous soon enoughsiLenTz will become famous soon enough
It is very simple:

Code:
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, i, j;
    printf("How many rows you want to show?: ");
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        int c = 1;
        for(j=i; j>=0; j--) {
            printf(" %d", c);
            c = c * j/(i-j+1);
        }
        printf("\n");
    }
}

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following 2 Users Say Thank You to siLenTz For This Useful Post:
HelloWorld (12-04-2007), TeraTask (12-05-2007)
  #5 (permalink)  
Old 12-04-2007, 05:16 PM
trowa0830 trowa0830 is offline
Novice
Join Date: Dec 2007
Posts: 7
iTrader: (0)
trowa0830 is on a distinguished road
thnx.. i have tried it but the output isn't shaped like triangle only the half does..

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #6 (permalink)  
Old 12-04-2007, 11:01 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Quote:
Originally Posted by trowa0830 View Post
i need help in programming a pascal triangle in turbo using for loops.. can some one help me.. can you please send it in my email.. thanks in advance...
Luckily you meet with my nice friend SiLent, other than him, I won't help you out if you won't give us what you got so far lol...

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to HelloWorld For This Useful Post:
TeraTask (12-05-2007)
  #7 (permalink)  
Old 12-04-2007, 11:44 PM
trowa0830 trowa0830 is offline
Novice
Join Date: Dec 2007
Posts: 7
iTrader: (0)
trowa0830 is on a distinguished road
output.txt

can you take a look at this...

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #8 (permalink)  
Old 12-05-2007, 12:03 AM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
It's better if you can use the CODE tag...

Code:
	printf("%39d ",a[1][1]);

	a[2][1]=1;a[2][2]=2;a[2][3]=1;

	printf("\n%37d %d %d ",a[2][1],a[2][2],a[2][3]);
	for(i=3;i<=n;i++)
	{
		a[i][1]=1;
		printf("\n%36d ",a[i][1]);

		j=2;c=3;
		while(j<=i)
		{
			a[i][j]=a[i-1][c-1]+a[i-1][c-2];
			printf("%d ",a[i][j]);
			c=c+1;
			j=j+1;
		}
		a[i][j]=1;
		printf("%d",a[i][j]);

	}
	getch();
}



*******************output*********************
enter how many lines you want: 7

				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
                             1 7 21 35 35 21 7 1


i have problems in making the shape a triangle..
so that I don't need to download stuff lol... I'll look over ur code, this is a logical problem

HINT: there's sequence of space on the triangle, print that one first, then you print the number

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to HelloWorld For This Useful Post:
TeraTask (12-05-2007)
  #9 (permalink)  
Old 12-05-2007, 12:46 AM
trowa0830 trowa0830 is offline
Novice
Join Date: Dec 2007
Posts: 7
iTrader: (0)
trowa0830 is on a distinguished road
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
 int a[10][10];
 int i,j,c,n;
 clrscr();
 printf("enter how many line do you want: ");
 scanf("%d",&n);
 a[1] [1]=1;
 printf("%39d ",a[1][1]);
 a[2][1]=1;a[2][2]=2;a[2][3]=1;
 printf("\n%37d %d %d ",a[2][1],a[2][2],a[2][3]);
 for(i=3;i<=n;i++)
 {
  a[i][1]=1;
  printf("\n%36d ",a[i][1]);
  j=2;c=3;
  while(j<=i)
  {
   a[i][j]=a[i-1][c-1]+a[i-1][c-2];
   printf("%d ",a[i][j]);
   c=c+1;
   j=j+1;
  }
  a[i][j]=1;
  printf("%d",a[i][j]);
 }
 getch();
}
 
*******************output*********************
enter how many lines you want: 7
                                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
                             1 7 21 35 35 21 7 1
 
i have problems in making the shape a triangle..
here.. hehehe.. thnx... for the advise..

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #10 (permalink)  
Old 12-05-2007, 07:32 AM
siLenTz's Avatar
siLenTz siLenTz is offline
Jr. Programmer
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Posts: 87
iTrader: (0)
siLenTz will become famous soon enoughsiLenTz will become famous soon enough
I was surprised because you didn't know how to make it shape like Pyramid.
It's not hard; you only need to create one loop for print repeated tabs.
For example: I want to print 5 rows of Pascal Triangle. In this case, for the
first row I would print 5 tabs; for the second row, I will print 4 tabs.; and so on.
And each number will be 2 tabs distance from each other.
Here my output concept: (___ represent for tab)

___ ___ ___ ___ ___ 1
___ ___ ___ ___ 1__ ___ 1
___ ___ ___ 1__ ___ 2__ ___ 1
___ ___ 1__ ___ 3__ ___ 3__ ___ 1
___ 1__ ___ 4__ ___ 6__ ___ 4__ ___1

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to siLenTz For This Useful Post:
HelloWorld (12-05-2007)
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 02:37 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50