Key features:
1. "both my programs should run in a sequential manner."
2. "when i close source.cpp then source1.cpp automatically debugs and runs."
Multithreading won't help here. I'll ignore the "debugs" in your request and assuming you really just want the second program to execute. I assume the two programs are named source.exe and source1.exe.
Use a command file.
https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/start.mspx?mfr=true
Create a command file. We'll call it two.cmd:
start /wait \path\to\source.exe
start /wait \path\to\source1.exe
The advantage is you do not need to modify either program. This isn't limited to Windows. You can do the same from a bash script too.
. /path/to/source
. /path/to/source1