C program to shut down or turn off computer

In this tutorial you will learn about the C program to shut down or turn off computer and its application with practical example.

C program to shut down or turn off computer

In this tutorial, we will learn to create a C program that will shut down or turn off the computer using C programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • Header Libraries and its usage.

Shut down or Turn off computer

In c programming it is possible shut down or turn off with the help of very small amount of code . The C language has many types of header libraries which has supported function in them with the help of these files the programming is easy.

Shutting Pc with the help of c program is so easy.

Algorithm:-

Program to shut down or turn off the computer :-

Program For Windows 7:-

Note to shutdown immediately use “C:\\WINDOWS\\System32\\shutdown -s -t 0”. To restart use “-r” instead of “-s”.

Here, “shutdown /s /t x”; where x is the number of seconds after which shutdown will occur.

Program For Windows xp:-

Note to shutdown immediately use “C:\\WINDOWS\\System32\\shutdown -s -t 0”. To restart use “-r” instead of “-s”.

Here, “shutdown /s /t x”; where x is the number of seconds after which shutdown will occur.

Program for Ubuntu:-

 

Output:-

The program we have to first include stdlib.h and then we call the system function.

In this tutorial we have learn about the C program to shut down or turn off computer and its application with practical example. I hope you will like this tutorial.