program to tell if a number is a perfect square

#include <iostream>
#include <cmath>

bool isPerfectSquare(int num) {
    if (num < 0) {
        return false;
    }
    int root = sqrt(num);
    return (root * root == num);
}

int main() {
    int number;
    std::cout << "Enter a number: ";
    std::cin >> number;
    if (isPerfectSquare(number)) {
        std::cout << number << " is a perfect square." << std::endl;
    } else {
        std::cout << number << " is not a perfect square." << std::endl;
    }
    return 0;
}

This program checks whether a given number is a perfect square by calculating the square root of the number and then comparing the product of the square root with itself to the original number. If the product is equal to the original number, then the number is a perfect square.