473,395 Members | 1,411 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

2 Matrices

Just wondering how I can do an input on 2 different buffers (P & Q). Here's what I've got so far.

#include <iostream>
using namespace std;

const int SIZE = 3;
int P[3][3];
int Q[3][3];
int row;
int col;

int main()
{
int P[3][3]
{
cout << "Enter " << SIZE << " rows of " << SIZE << " integers each:\n";
for (row = 0; row < SIZE; row++)
for (col = 0; col < SIZE; col++)
cin >> P[row][col];

cout << "Displaying:\n";
for (row = 0; row < SIZE; row++)
{
for (col = 0; col < SIZE; col++)
cout << P[row][col]<< " ";
cout << endl;
}
}

int Q[3][3]
{
cout << "Enter " << SIZE << " rows of " << SIZE << " integers each:\n";
for (row = 0; row < SIZE; row++)
for (col = 0; col < SIZE; col++)
cin >> Q[row][col];

cout << "Displaying:\n";
for (row = 0; row < SIZE; row++)
{
for (col = 0; col < SIZE; col++)
cout << Q[row][col]<< " ";
cout << endl;
}
}

return 0;
}
Apr 7 '08 #1
1 1073
weaknessforcats
9,208 Expert Mod 8TB
const int SIZE = 3;
int P[3][3];
int Q[3][3];
int row;
int col;
These global variables should be local variables inside main().

Then remove the int P[3][3] Q[3][3] in main().

That should get your code to compile.
Apr 8 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nils Wagner | last post by:
Hi all, Has someone written a C binding to transfer matrices from C to Python and vice versa ? Any pointer would be appreciated. Nils
3
by: tommy | last post by:
Hello everyone, I'm trying to write a program which will be adding and subtracting two matrices. I've already written some code but there are a few problems. 1) During compilation I get this...
8
by: Noesis Strategy | last post by:
I am attempting to build a database that profiles about 50 companies in a single industries. In a standard MS Word format, each profile would be about 20 pages of dense text and tables. In order...
3
by: Prototipo | last post by:
Hi! I need to dynamically create X vectors of matrices (with a known size of 5x5). It's like a three-dimensional matrix with 2 known dimensions and the third unknown. I have something like: ...
5
by: Frederic Soustra | last post by:
Hi, I am trying to speed up some work I have to do with a 3D Matrix. If I am not mistaken, C is row major, hence the matrix A of size 2 x 2 x 2 would be stored like this in memory:...
1
emaghero
by: emaghero | last post by:
Does anybody know an algorithm for the fast multiplication of three n-x-n symmetric matrices? I have an algorithm, which I'm not too pleased with, that does the job. Does anybody know a faster...
9
by: tomamil | last post by:
imagine that you have different matrices with different names and you want to perform the same action with each of them. is it possible to put their names into some array and to create a loop that...
5
by: td0g03 | last post by:
This program adds two square matrices - Algorithm 1-3, Page 35. Change it to implement the generalized algorithm to add two m x n matrices. Matrices, in general, are not square or n x n...
2
by: debiasri | last post by:
I have to devide a matrix in variable no of matrices with each having variable no of rows. Like I have to devide a matrix with dim.9X19 into say 4 matrices with row nos 1,6,6,6 respectively, and I...
5
by: adinda | last post by:
So what i need is this; (I'm very new at this,, programming in C I mean...) In matlab I had a while loop, and after each loop was done I added my resulting matrix to an object. Seeing the loop...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.