Fill This Form To Receive Instant Help
Homework answers / question archive / C++ Attached is a C++ program four of us did many years ago
C++
Attached is a C++ program four of us did many years ago.I have a much better understanding of C++ than Matlab, but in this program their are many arrays I think in the form of for example j[]=[3 5 6], etc. First, I am terrible at arrays and through this program, which another guy took care of the arrays part since he did a previous robot arm movement program before this program was made did the array parts.
First, please help me...An array is nothing more than a row vector or like in MAtlab right, which stores a set of numbers to be used elsewhere right?
Second, now some are in form j[] and some in form j[10], what is difference?
Next, look at the fprint statements on the 3rd page of the program attached. What does thefprintf(stdprn,I%d,....do and what is going on with that code compared to the rest of the code, then fprintf(stdprn, S5/nN...etc. Explain all this please!
Fouth, in the same routine on 3rd page for example, for int (j=0; j<6, j++) I know this for loop takes all 10 values from each array and outputs them somehow - explain how, and also in the code routine you have arrays b5 - h5, the the for loop using the variable j. OK, in programming or this program how does the for loop know to execute each array b5 - h5 and its elements if the variable j in the for loop does not have any connection with the arrays? In other words I do not see how hte code works, or is it just the fact as the code executes from the fisrt line to the last the code is in order. Bare with me. As the arrays b5 - h5 etc are listed in the code, or its order, the next statement of the for loop is basically just execusted for the arrayss. In other words C++ looks above the for loop code and says, oh, everything above me needs to be outputted until my for loop according to the boundaries set( j=0; j<6, j++) , then go to the next line of code beneath me and keep running the program till the end, etc? Is this logic correct?
1. In C++, array may be a row vector, a column vector or an n-dimensional matrix A(i,j) such that the first index 'i' is row, second index 'j' is column. You are right, basically it stores numbers.
2. j[]={3 5 6} means a definition of a row vector with its array elements. j[10] means the 10-th element. In case of j[], j[0]=3, j[1]=5, j[2]=6. By the by in C or C++, the first element index is 0.
3. The fprintf command is used to write in stream. Here stdprn is the stream. In some case one may put handler for some file so that program may write in the file. Since the code deals with the robotic writing then it must be the port for that. Here stdprn stands for standard printer. Now after stdprn, the code informs the format for the variables to be written. The complete definition of formatting output variables needs a complete chapter in a book and certainly beyond the scope of this PROBLEM!!!!! I request the student to consult any book on basic C language like the book of Gottfried.
4. You are wrong. In page 3, where it states "for(int j=0; j<6; j++)" the loop is executed for only j=0 to j=5 means 6 times. It can't execute for 10 times by this command. Just notice some lines below there is another command "for(int j=0; j<10; j++)" which states that j to be executed from value 0 to 9 which means for 10 times. This command simply states that variable j is declared as integer which starts from 0 then executes whatever is under this for loop and after that increments j by 1. If value of j is less than 10 then continue else end of for loop. However, these loops are defined in functions like P, S, A etc. In main if choice3 variable is set to 'y' then they are called serially and accordingly codes are executed as revealed in page 1.