Shutdown computer and laptop by Turbo C


Code for WindowXP
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>

void main()
{   
char shutdown;   
clrscr();   
gotoxy(15,5);
printf("Shutdown your computer now ? (y/n)\n\n\t Answer : ");   
gotoxy(20,7);
scanf("%c",&shutdown);   
if (shutdown == 'y' || shutdown == 'Y')
{
system("C:\\WINDOWS\\System32\\shutdown -s");
}

Code for Ubuntu Linux
#include<stdio.h> 
void main() 
{  
system("shutdown -P now");
}  

Code for Window7

#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void main()
{   
char shutdown;   
clrscr();   
gotoxy(15,5);
printf("Shutdown your computer now ? (y/n)\n\n\t Answer : ");   
gotoxy(20,7);
scanf("%c",&shutdown);   
if (shutdown == 'y' || shutdown == 'Y')      
{
system("C:\\WINDOWS\\System32\\shutdown \s");
}

Save program with '.c' extension.
for example shutdown.c

ALT +  F9  through COMPILE program.


CTRL + F9   through RUN program.
  

Thank you for read post.

No comments: