I recently started learning cpp and i encountered with this problem
which i searched for and understood it need some configurations on json file and building exe file of the code to be able to run and debug
which i found out C/C++ Compile Run
extention will automatically do it all
https://marketplace.visualstudio.com/items?itemName=danielpinto8zz6.c-cpp-compile-run