C++ Programming Code Examples C++ > Beginners Lab Assignments Code Examples Programming Code to Shutdown Computer Programming Code to Shutdown Computer To shutdown and restart you computer using C++ programming, just call the function system() of stdlib.h library which will call the cmd or terminal. So to shutdown and restart your computer, just place your code (including full path) to shutdown and restart your computer. Here, we provided three programs to shutdown and restart your computer. The first program is to shutdown your computer system. The second program is to restart your computer and the third program is for both shutdown and restart your computer (this program is menu-driven). Following C++ program shutdown your computer system after 20 seconds. #include<stdlib.h> void main() { system("c:\\windows\\system32\\shutdown /s /t 20 \n\n"); }