Shutdown your Computer using C Programming Language

Hi friends! It is quite boring to shutdown your computer in windows by pressing windows button and then shutdown button and in ubuntu by pressing button on the corner of your pc.
Today I will talk you to how to shutdown your computer using c programming language.

/* ******************** Linux Operating System ****************** */
#include <stdio.h>
 int main() {
  system("shutdown -h now");
  return 0;
}
/* ******************* Linux Operating System ******************** */
Here shutdown -h now is command used for shut down Linux based operating system.There are also some other commands which are also used for shutdown system.

/* **************** Windows XP Operating System *************** */
 C programming code for Windows XP

#include <stdio.h>
#include <stdlib.h>

int main()
{
   char ch;

   printf("Do you want to shutdown your computer now (y/n)\n");
   scanf("%c", &ch);

   if (ch == 'y' || ch == 'Y')
      system("C:\\WINDOWS\\System32\\shutdown -s");

   return 0;
}

/* **************** Windows XP Operating System *************** */


/* **************** Windows 7 Operating System *************** */

#include <stdio.h>
#include <stdlib.h>

int main()
{
   system("C:\\WINDOWS\\System32\\shutdown /s");

   return 0;
}
/* **************** Windows 7 Operating System *************** */

Comments

Popular posts from this blog

Export data from mysql db to csv file using java

Secure Database Connectivity in node.js with mysql

Java Web Scraping