write a program that prints all perfect squares found in each row of a matrice.
1
Expert's answer
2013-03-15T10:04:20-0400
#include <iostream> #include <cmath>
using namespace std;
const int n = 3;
typedef int Matrix[n][n];
/* Returns true if the given number is a perfect square */ bool check_number(int number) { double sqrt = sqrt(number); return (sqrt * sqrt == number); }
/* Finds and prints all matrix elements & * which are perfect squares */ void find_numbers(Matrix& matrix) { for (int x = 0; x < n; x++) for (int y = 0; y < n; y++) if (check_number(matrix[x][y])) cout << matrix[x][y] << endl;
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
You're welcome. We are glad to be helpful. If you really liked our service please press like-button beside answer field. Thank you!