CONTROL YOUR COMPUTER BY "C" PROGRAM

Q Write a program to restart and turnoff your computer.

CODE:
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
#include<string.h>
 void XP1(char);
 void W7(char);
 void li(char);
int main()
{
   char ch;
   int OS;

   do{
    printf("\nEnter S for Turn off\nEnter R for Restart:     ");fflush(stdin);
    scanf("%c",&ch);
    }while(ch!='r' && ch!='R' && ch!='s' && ch!='S');

   printf("\n\nEnter your Operting system:\n 1 = WINDOWS XP\n 2 = WINDOWS7\n 3 = Linux");
   scanf("%d",&OS);

if(OS == 1)
XP1(ch);
else
if(OS == 2)
W7(ch);
else
li(ch);


   return 0;
}

  void XP1(char c)
{
if(c == 's' || c == 'S')

system("C:\\WINDOWS\\System32\\shutdown -s");
else
   system("C:\\WINDOWS\\System32\\shutdown -r");
}

 void W7(char d)
{
if(d == 's' || d == 'S')
system("C:\\WINDOWS\\System32\\shutdown /s");
else
system("C:\\WINDOWS\\System32\\shutdown /r");
}
 void li(char e)
{
if(e == 's' || e == 'S')
system("C:\\WINDOWS\\System32\\shutdown /s");
else
   system("C:\\WINDOWS\\System32\\shutdown /r");
}



OUTPUT:


DISCUSSION:   This is program where we can control our computer. We can restart, turnoff of the computer depend on the operating system of the computer like WINDOWS XP , WINDOWS 7 , LINUS . Almost all types of WINDOWS OS can control with this program (WINDOWS 8).





Translate