Ask your own question, for FREE!
Computer Science 9 Online
OpenStudy (anonymous):

Make and run a program that will display the numbers 1, 2, 3, and so on depending on the number of lines the user will enter. For example, if input=3, first line of output should be 1, next line 2 3, and the last line 4 5 6 using a do-while loop. I'm using c++, I can't solve this problem. Can you please help me out? ASAP

OpenStudy (anonymous):

I don't know c++ but I can give you program in c. #include<stdio.h> #include<conio.h> void main() int i=1, n; scanf ("%d", &n); if (i<=n) printf("%d /n", &n); i++; else getch(); if you are learning c++ then this means that you already know c language. you just need to convert the above code into c++ syntax. NOTE: THE ABOVE CODE WILL GIVE YOU A BASIC IDEA OF WHAT HAS TO BE DONE. SOMETHING LIKE AN ALGORITHM.

OpenStudy (e.mccormick):

anuragbansal, never assume that "if you are learning c++ then this means that you already know c language. you just need to convert the above code into c++ syntax." Many people are taught C++ without learning C. In fact, C is now being taught later and later, if at all, because it has returned to more of an operating system development language while other languages have become more general purpose.

OpenStudy (queelius):

mguy1, can you describe to me how you would solve this problem in English (or some other more familiar computer programming language). Once you got a handle on how to solve this problem, you can work on converting it to C++.

OpenStudy (rsmith6559):

do { int i = 0; // read a line of input cout << ++i << input << endl; } while( !feof );

OpenStudy (anonymous):

Hello, mguy1. I'm a beginner in C programming. I dnt knw if you have succeded. But, i coded in C (code::blocks) and i got the program working.

OpenStudy (anonymous):

here's the code: #include <stdio.h> void main() { int i,j,n; printf("Enter the degree: "); scanf("%d",&n); int t[n][n]; for(i=0;i<n;i++) { t[0][0]=0; t[i][0]=t[i-1][i-1] + 1; for(j=1;j<=i;j++) { t[i][j]=(t[i][j-1]) + 1; } } for(i=0;i<n;i++) { for(j=0;j<=i;j++) { printf("%5d",t[i][j]); } printf("\n"); } }

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!