MCPcopy Create free account
hub / github.com/Rustam-Z/cpp-programming / sum_matrices

Function sum_matrices

Lab_09/Source1.cpp:132–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132void sum_matrices()
133{
134 system("cls");
135 cout << "\t\tSUM TWO MATRICES\n";
136 cout << "\tNOTE: Rows 1 = Rows 2 && Columns 1 = Columns 2\n";
137 cout << "Please input details for the First Matrix: \n";
138 int row_input, col_input;
139 cout << "Rows (max 5): ";
140 cin >> row_input;
141 cout << "Columns (max 5): ";
142 cin >> col_input;
143 int a[5][5];
144 cout << "Now input elements of First Matrix: ";
145 if (row_input > 0 && row_input <= 5 && col_input > 0 && col_input <= 5)
146 {
147 for (int row = 0; row < row_input; row++)
148 {
149 for (int col = 0; col < col_input; col++)
150 {
151 cin >> a[row][col];
152 }
153 }
154 cout << "First Matrix: \n";
155 for (int row = 0; row < row_input; row++)
156 {
157 for (int col = 0; col < col_input; col++)
158 {
159 cout << a[row][col] << " ";
160 }
161 cout << endl;
162 }
163 }
164 else
165 {
166 system("cls");
167 cout << "Please input valid numbers from 1 to 5 ! " << endl;
168 read_display();
169 }
170 // for the second matrix
171 cout << endl;
172 cout << "Please input details for the Second Matrix: \n";
173 int row_input2, col_input2;
174 cout << "Rows (max 5): ";
175 cin >> row_input2;
176 cout << "Columns (max 5): ";
177 cin >> col_input2;
178 int b[5][5];
179 cout << "Now input elements of Second Matrix: ";
180 if (row_input2 > 0 && row_input2 <= 5 && col_input2 > 0 && col_input2 <= 5)
181 {
182 for (int row = 0; row < row_input2; row++)
183 {
184 for (int col = 0; col < col_input2; col++)
185 {
186 cin >> b[row][col];
187 }
188 }
189 cout << "Second Matrix: \n";

Callers 2

productFunction · 0.85
main22Function · 0.85

Calls 2

read_displayFunction · 0.85
mainFunction · 0.70

Tested by

no test coverage detected