| | |
to calculate square and cube form given input using arrays..
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
0
#11 Nov 10th, 2009
This should work now. You gotta learn arrays, passing arrays to functions, returning arrays, etc. profoundly in order to master arrays.
As pointed by jonsca, there are many tuts/ebboks on the 'firehose of information'(the Internet).
Cheers
C++ Syntax (Toggle Plain Text)
#include <cstdlib> #include <iostream> #include <iomanip> #include <cmath> using namespace std; const int size = 10; void square_store (int [], int []); void read_numbers (int []); void cube_store (int [], int []); int main(int argc, char *argv[]){ const int size = 10; static int values[size], square_array [size], cube_array[size]; int i [size]; read_numbers (values); square_store (square_array, values); cube_store (cube_array, values); cout << "\n\n"; system("PAUSE"); return EXIT_SUCCESS; }//main() ends void read_numbers (int values[]){ int index; cout << "Enter 10 numbers:\n"; for (index = 0; index < size; index++) cin >> values [index]; }//read_numbers() ends void square_store (int square_array[], int values[]){ int index; cout << "\nThe square of your input numbers are:\n"; for (index = 0; index < size; index++){ square_array [index] = values [index] * values [index]; cout << "\n\n"; cout << "Square is ---> " << square_array [index]; } }//square_store() ends void cube_store ( int cube_array[], int values[]){ int i; cout << "\n\nThe cubes of the numbers are:\n"; for (i = 0; i < size; i++){ cube_array [i] = values [i] * values [i] * values [i]; cout << "\n\n"; cout << "Cube is ---> " << cube_array[i]; } }//cube_store() ends
As pointed by jonsca, there are many tuts/ebboks on the 'firehose of information'(the Internet).
Cheers
PEACE !
![]() |
Similar Threads
- Change form input text using Javascript/Dom (JavaScript / DHTML / AJAX)
- Help with coding an application that will calculate the square and square root (Visual Basic 4 / 5 / 6)
- PHP Formula and syntax (PHP)
- calculate squares and cube (Java)
- Default Values of Text Field (JavaScript / DHTML / AJAX)
Other Threads in the C++ Forum
- Previous Thread: const char array problem
- Next Thread: Internet Provider Switch Program Help
Views: 451 | Replies: 10
| Thread Tools | Search this Thread |
Tag cloud for C++
api array arrays based beginner binary bmp c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete deploy dll download dynamic encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib library lines linkedlist linker list loop looping loops map math matrix memory microsoft newbie news number output pointer problem program programming project python random read recursion recursive reference return simple sort spoonfeeding string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets





