Creating a Matrix Using Turbo/Borland C++

Now we try to make a Matrix 3 x3 using Turbo/borlan C++. In C/C++, we use array algorithm for creating a matrix. Open Turbo/Borland C++, create new “cpp” file, type code like this:

Remember, if we use function ‘cout’ we must type at the header #include<iostream.h>. Look at carefully line int A[3][3]={1,2,3,4,5,6,7,8,9};. It means that we create a matrix 3×3 similar to matrix in matlab:

A=[1 2 3;4 5 6;7 8 9]

Loops ‘for’ at that code are only for showing the content of array/matrix A[3][3]. Try code for create matrix interactively using keyboard input. Use function ‘cin’ and loops ‘for’ for positioning the element of matrix.

Tinggalkan komentar

Situs ini menggunakan Akismet untuk mengurangi spam. Pelajari bagaimana data komentar Anda diproses.