In C++, a reference works as an alias for an existing variable, providing an alternative name for it and allowing…