| | write a program |
|
|
bro. you are giving spaces by space bar but i need it with the loopyeah u are right about pascal triangle but i need to generate it using c++ loops structure...
|
Heh, sounds like hmwk to me.
You'd probably want to do two while loops - one nested in the other - one for determining how many numbers to display, and the second displaying the numbers. Both of your outputs display numbers in increasing order, so you'd probably just reverse the increment/decrement in the outer loop and change the index variable to get the other. -Just an idea, you probably should look through tutorials and such. They normally cover this stuff in the example section. It isn't that hard to transcribe it for your case. Here comes the code. // Programs makes interesting output some sort of triangle with numbers. // HitmanBlood #include<iostream> using namespace std; int main(){ for(int j = -1; j <= 5; j++){ //First loop coordinates the raws for(int k = j + 1; k <= 5; k++){ // Cordinates this second loop for columns cout << k; } cout << endl; // Transfer to the new line that is new raw } //Second output for(int j = 6; j >= 1; j--){ // This loop is again coordinating raws for(int k = j - 1; k <= 5; k++){ // Second loop which is coordinating columns. cout << k; } cout << endl; // Transfer to the new line that is new raw } system("pause"); // If you are using linux just delete or comment this line } You see it is simple as that.
Its is soooooooooooooooo simple.... But Mr. hitmanblood made it in C++ and you said in C so take it in C.......
void main() { int i,j; clrscr(); printf("a.\n\n"); for(i=-1; i<=5; i++) { for(j=i+1; j<=5; j++) { printf("%d",j); } printf("\n"); } printf("\nb.\n\n"); for(i=6; i>=1; i--) { for(j = i-1; j<=5; j++) { printf("%d",j); } printf("\n"); } printf("\n\nplease help ...\n"); } By:Bhavesh
very good...well done
hey what is the logic behind pascal triangle please explain all it to me
and also explain the following program code to me as well (using loops) 1. ******** *S PACE* *S PACE* *S PACE* ******** (as spaces dont work here so i write space to fill the space) 2. A AB ABC ABCD ABCDE
What do Pascal triangles have anything to do with the previous posts? Wikipedia Pascal's Triangle if you really want to know.
#1 - are there actual newlines or are there just asterisks, three spaces, and more asterisks? #2 - Here's one way using alphanumerics: take any of the programs already given in code, remove the spaces, and then use a (char) adjusting for the ASCII table. You'd probably add 64 to each index, assuming A=1, B=2, etc.
i really dont get you osknockout what you are talking about i need help with this LOOP and i cannot understand ya single word.... i want to program it in C++ ...
a programmer known well what is pascal triangle ... Latest Entries
bro. you are giving spaces by space bar but i need it with the loop
yeah u are right about pascal triangle but i need to generate it using c++ loops structure...
Similar Topics
Keywords : looping, c
problems looping (5) I've recently started using streaming sound files, the make my swf's faster loading but i Looking for looping, c
|
|
![]() Looping Help C |
| ADD REPLY / Got an Opinion! | a humble request :-) | RAPID SEARCH! | Free Hosting | [X] |
|
Express your Opinions, Thoughts or Contribute your information that might help someone here. Ask your Doubts & Queries to get answers.. "Together, We enlight each other!" |
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP. | 500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE |
|