This is a C program to shutdown or turn off the computer in linux.
Problem Description
This program is used to shutdown or turn off the computer in linux.
Problem Solution
1. Use function system(“shutdown -P now”) to shutdown or turn off the computer in linux.
2. Exit.
Program/Source Code
Here is source code of the C Program to shutdown or turn off the computer in linux. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C Program to Shutdown or Turn Off the Computer in Linux.
*/
#include <stdio.h>
int main()
{
system("shutdown -P now");
return 0;
}
Program Explanation
1. Use function system(“shutdown -P now”) in the main function to shutdown or turn off the computer in linux.
2. Exit.
advertisement
advertisement
Runtime Test Cases
shutdown: Need to be root
Sanfoundry Global Education & Learning Series – 1000 C Programs.
Here’s the list of Best Books in C Programming, Data-Structures and Algorithms
Participate in C Programming Certification Contest of the Month Now!
If you wish to look at other example programs on Simple C Programs, go to Simple C Programs. If you wish to look at programming examples on all topics, go to C Programming Examples.
Next Steps:
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Related Posts:
- Practice BCA MCQs
- Practice Computer Science MCQs
- Buy C Books
- Watch Advanced C Programming Videos
- Apply for C Internship