C Program to shutdown or turn off your computer

C Program to shutdown your computer

C Program to turn off your computer. in this program we will learn how to shutdown your computer using c program. there the system ask to the user if you press the ‘y’ key then the computer will automatically shutdown within 30 seconds and if you press ‘n’ key the computer will not shutdown.

there we will the apply the shutdown operation on the system32 directory in various windows operating system. first your should find the shutdown.exe file path and that path will give in the command which we use in our program.
so let have a look on the program.

ALGORITHM:-
Step 1: import the respective package
Step 2: import the stdlib.h directory
Step 3: Declare a character type variable and read from user
Step 4: if user press yes, then the shutdown.exe file path should execute
Step 5: terminate the program

PROGRAM CODE:-
#include<stdio.h>
#include<stdlib.h>

void main()
{
char c;
printf("if you want to shutdown press y either n");
scanf("%c",&c);

if(c=='y')
{
system("c:\windows\systemshutdown -s");
}
}


OUTPUT:-
The computer will shutdown in 30 second


How to turn off our computer using c program
C Program to shutdown your computer
C program to turn off your computer