How to Restart PC with C++ Program

With this program a user can restart computer with C++ program . System class is used to restart the computer and we just pass the parameter 'system-r' to system class and this piece of code restart the computer .

Source Code

#include <iostream>
#include <windows.h>
using namespace std;

int main()
{
 char choice ;
 cout<<" \t \t \t LEP Tutorials \n \n "<<endl;
 cout<<" Do You Want to Restart PC ? Y/N "<<endl;
 cout<<" ";
 cin>>choice;
 if ((choice =='y' )||(choice =='Y' ))
 {
 system("shutdown -r");
 }
 else
 {
 return 0;
 }
}

Output of the Program

Restart PC with C++ Program

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment