pascal triangle?

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2007
Posts: 6
Reputation: stringgader is an unknown quantity at this point 
Solved Threads: 0
stringgader stringgader is offline Offline
Newbie Poster

pascal triangle?

 
0
  #1
Mar 4th, 2007
hi, nu member hir, just hav some question regarding this output:
  1. 1
  2. 232
  3. 34543
  4. 4567654
  5. 567898765
  6. 67890109876
  7. 7890123210987
  8. 890123454321098
  9. 90123456765432109
  10. 0123456789876543210
numbers that are alligned with 1 are

3
5
7
9
1
3
5
7
9

these are the middle numbers...

does anybody know how to do this in c language? or to look for its formula? tnx alot,,
Last edited by WaltP; Mar 5th, 2007 at 12:37 am. Reason: Try CODE tags -- that way explanations don't havfe to be confusing.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,678
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1504
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: pascal triangle?

 
0
  #2
Mar 4th, 2007
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,131
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 283
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: pascal triangle?

 
0
  #3
Mar 5th, 2007
Originally Posted by stringgader View Post
does anybody know how to do this in c language? or to look for its formula? tnx alot,,
Yes, many of us know how to do this. The question is: do you? Or can you figure it out?

If you need help, asking specific questions and posting code you've tried will get excellent answers.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 6
Reputation: stringgader is an unknown quantity at this point 
Solved Threads: 0
stringgader stringgader is offline Offline
Newbie Poster

Re: pascal triangle?

 
0
  #4
Mar 5th, 2007
no i cant, thats why im asking for someone hu can help me do thiis ,, its actually a problem,, twas given by our instructor and wants us to figure it out,, thats why ide like to gather any idea or information regarding this thing,,, tnx for the reply...
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 6
Reputation: stringgader is an unknown quantity at this point 
Solved Threads: 0
stringgader stringgader is offline Offline
Newbie Poster

Re: pascal triangle?

 
0
  #5
Mar 5th, 2007
by the way,, im only new to this programming thing,, tnx again
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 7
Reputation: goutham_see is an unknown quantity at this point 
Solved Threads: 0
goutham_see goutham_see is offline Offline
Newbie Poster

Re: pascal triangle?

 
1
  #6
Mar 5th, 2007
TRY THIS OUT

  1. #include<stdio.h>
  2. main()
  3. {
  4. int i,j,k;
  5. printf("\n");
  6. for(i=1;i<=10;i++)
  7. {
  8. for(j=1;j<=31-i;j++)printf(" ");
  9. for(j=i,k=(2*i-1)/2+1;k;j++,k--)
  10. {
  11. if(j==10)j=0;
  12. printf("%d",j);
  13. }
  14. for(j-=2,k=(2*i-1)/2;k;j--,k--)
  15. {
  16. if(j==-1)j=9;
  17. printf("%d",j);
  18. }
  19. printf("\n");
  20. }
  21. }
Last edited by ~s.o.s~; Mar 5th, 2007 at 12:07 pm. Reason: Added code tags, learn to use them.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,131
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 283
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: pascal triangle?

 
0
  #7
Mar 5th, 2007
Originally Posted by goutham_see View Post
TRY THIS OUT
goutham, around here we want the poster to find the answer. We help them with their code, we don't do their homework for them.


stringgader, read the above. In order to get this problem from your instructor, you must know something about code. This can't possibly be your first program.
Originally Posted by stringgader View Post
by the way,, im only new to this programming thing,, tnx again
Duh, really?
Last edited by WaltP; Mar 5th, 2007 at 3:46 pm.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,678
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1504
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: pascal triangle?

 
0
  #8
Mar 5th, 2007
Originally Posted by stringgader View Post
no i cant, thats why im asking for someone hu can help me do thiis ,, its actually a problem,, twas given by our instructor and wants us to figure it out,, thats why ide like to gather any idea or information regarding this thing,,, tnx for the reply...
Go back and read the thread link that I posted, it contains the answer to your problem. If you don't understand the posted code to that thread then I doubt you are ready for the course you are taking. The proglem is a little too advanced for someone completly new to programming and C language in particular.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 6
Reputation: stringgader is an unknown quantity at this point 
Solved Threads: 0
stringgader stringgader is offline Offline
Newbie Poster

Re: pascal triangle?

 
0
  #9
Mar 6th, 2007
ei,, tnx again for your replies,,,
yup im only new to this, im already working on this for 2 weeks,, this is my code:
  1. #include<stdio.h>
  2. int value,count1,count2,count3,temp;
  3. main()
  4. {
  5. clrscr();
  6. temp=1;
  7. printf("Enter number of rows:");
  8. scanf("%d", &value);
  9.  
  10.  
  11. for(count1=1; count1<=value; count1++)
  12. printf(" ");
  13. {
  14. for(count2=value; count2>=count1; count2--)
  15. printf(" ");
  16. for(count3=1; count3<=temp; count3++)
  17. printf("%d",count1,count2,count3);
  18. printf("\n");
  19. temp+=2;
  20. }
  21. getche();
  22. }

but, my output is this:
  1. 1
  2. 222
  3. 3333
  4. 44444
  5. 555555
  6. etc......
i bet i got a wrong formulation for this stuff, and my deadline is on saturday,, hoping 4 ur nice consideration... tnx alot
Last edited by WaltP; Mar 6th, 2007 at 12:26 pm. Reason: Added code tags, learn to use them. And use the PREVIEW button...
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,048
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 179
Aia's Avatar
Aia Aia is offline Offline
Postaholic

Re: pascal triangle?

 
1
  #10
Mar 6th, 2007
@ stringgader. The code that goutham_see posted for you, works very well. Why don't you compare his with yours and learn what is not working with yours?.

In your last post I see that you make the declaration of variables ALL Global. I don't think that's what you want even when is going to work. What you want to do is to declare them after the left bracket in main, in this case.

The function:
clrscr();
is not necesary there. Is not doing anything for your, and above anything else, it makes your code not portable, which is something that you should always shoot for.

Same with
getche();
your could very well use the standard getchar().
Last edited by Aia; Mar 6th, 2007 at 6:48 pm. Reason: not important to know
"If it moves, tax it. If it keeps moving, regulate it, and if it stops moving, subsidize it" - Ronald Reagan
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 3840 | Replies: 10
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC