| | |
pascal triangle?
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2007
Posts: 6
Reputation:
Solved Threads: 0
hi, nu member hir, just hav some question regarding this output:
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,,
C Syntax (Toggle Plain Text)
1 232 34543 4567654 567898765 67890109876 7890123210987 890123454321098 90123456765432109 0123456789876543210
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.
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.
•
•
•
•
does anybody know how to do this in c language? or to look for its formula? tnx alot,,
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
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
•
•
Join Date: Feb 2007
Posts: 7
Reputation:
Solved Threads: 0
TRY THIS OUT
c Syntax (Toggle Plain Text)
#include<stdio.h> main() { int i,j,k; printf("\n"); for(i=1;i<=10;i++) { for(j=1;j<=31-i;j++)printf(" "); for(j=i,k=(2*i-1)/2+1;k;j++,k--) { if(j==10)j=0; printf("%d",j); } for(j-=2,k=(2*i-1)/2;k;j--,k--) { if(j==-1)j=9; printf("%d",j); } printf("\n"); } }
Last edited by ~s.o.s~; Mar 5th, 2007 at 12:07 pm. Reason: Added code tags, learn to use them.
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.
Duh, really?
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.
•
•
•
•
by the way,, im only new to this programming thing,, tnx again
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
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
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.
•
•
Join Date: Mar 2007
Posts: 6
Reputation:
Solved Threads: 0
ei,, tnx again for your replies,,,
yup im only new to this, im already working on this for 2 weeks,, this is my code:
but, my output is this:
i bet i got a wrong formulation for this stuff, and my deadline is on saturday,, hoping 4 ur nice consideration... tnx alot
yup im only new to this, im already working on this for 2 weeks,, this is my code:
c Syntax (Toggle Plain Text)
#include<stdio.h> int value,count1,count2,count3,temp; main() { clrscr(); temp=1; printf("Enter number of rows:"); scanf("%d", &value); for(count1=1; count1<=value; count1++) printf(" "); { for(count2=value; count2>=count1; count2--) printf(" "); for(count3=1; count3<=temp; count3++) printf("%d",count1,count2,count3); printf("\n"); temp+=2; } getche(); }
but, my output is this:
C Syntax (Toggle Plain Text)
1 222 3333 44444 555555 etc......
Last edited by WaltP; Mar 6th, 2007 at 12:26 pm. Reason: Added code tags, learn to use them. And use the PREVIEW button...
@ 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:
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 your could very well use the standard getchar().
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();
Same with
•
•
•
•
getche();
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
![]() |
Similar Threads
- C++ codes for pascal triangle (C++)
- Help With Pascal's Triangle in C++ (C++)
- Custom pascal triangle ? (C)
- Need Help With Printing Pascal's Triangle In C (C)
Other Threads in the C Forum
- Previous Thread: Project
- Next Thread: Need help with string manipulation and seg faults
Views: 3840 | Replies: 10
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays bash binarysearch centimeter char character convert copyanyfile copypdffile createcopyoffile createprocess() csyntax directory drawing dynamic executable feet fflush file floatingpointvalidation fork frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o ide infiniteloop initialization interest intmain() kilometer lazy license linked linkedlist linux linuxsegmentationfault list match matrix meter microsoft multi mysql oddnumber odf open openwebfoundation pattern pause pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition scheduling segmentationfault send shape single socketprogramming spoonfeeding stack standard strchr string strings structures student suggestions system test testautomation unix urboc user visualstudio voidmain() win32 win32api windows.h






