Bob P. answered 07/15/23
Macintosh, Windows, iPhone and iPad Training and Problem Solving
Just to add to the previous answer, you can only use an iMac as an external monitor for models created in 2014 or earlier. Apple took away this function, called Target Display Mode in iMacs built after 2014.
Here is an Apple Support page which explains how to used Target Display Mode: https://support.apple.com/en-us/HT204592