• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to create a simple C program on Debian 12

  • 00:35 cat /etc/os-release
  • 00:49 apt update
  • 01:12 apt install build-essential
  • 01:29 nano test.c
  • 02:43 gcc test.c -o ctest
  • 02:45 ./ctest
{{postValue.id}}

To Create Simple C Program On Debian 12

Introduction

C is a widely utilized programming language recognized for its simplicity and efficiency. Developed in the early 1970s, it has become a fundamental building block for numerous modern programming languages. C is especially favored in system programming, embedded systems, and application development due to its capability to interact closely with hardware.

Procedure :

Step 1 : Check the OS version by using following command.

root@linuxhelp:~# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Step 2 : Update the system packages by using following command.

root@linuxhelp:~# apt update
Get:1 http://security.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:2 http://deb.debian.org/debian bookworm InRelease [151 kB]               
Get:3 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
Get:4 http://security.debian.org/debian-security bookworm-security/main Sources [120 kB]
Get:5 http://security.debian.org/debian-security bookworm-security/main amd64 Packages [188 kB]
Get:6 http://security.debian.org/debian-security bookworm-security/main Translation-en [115 kB]
Get:7 http://deb.debian.org/debian bookworm/main Sources [9,487 kB]
Get:8 http://deb.debian.org/debian bookworm/non-free-firmware Sources [6,436 B]
Get:9 http://deb.debian.org/debian bookworm/main amd64 Packages [8,787 kB]
Get:10 http://deb.debian.org/debian bookworm/main Translation-en [6,109 kB]
Get:11 http://deb.debian.org/debian bookworm/non-free-firmware amd64 Packages [6,236 B]
Get:12 http://deb.debian.org/debian bookworm/non-free-firmware Translation-en [20.9 kB]
Get:13 http://deb.debian.org/debian bookworm-updates/main Sources.diff/Index [11.7 kB]
Get:14 http://deb.debian.org/debian bookworm-updates/main amd64 Packages.diff/Index [11.7 kB]
Ign:14 http://deb.debian.org/debian bookworm-updates/main amd64 Packages.diff/Index
Get:15 http://deb.debian.org/debian bookworm-updates/main Translation-en.diff/Index [11.7 kB]
Ign:15 http://deb.debian.org/debian bookworm-updates/main Translation-en.diff/Index
Get:16 http://deb.debian.org/debian bookworm-updates/main Sources T-2024-09-10-2011.55-F-2024-04-23-2036.10.pdiff [1,206 B]
Get:16 http://deb.debian.org/debian bookworm-updates/main Sources T-2024-09-10-2011.55-F-2024-04-23-2036.10.pdiff [1,206 B]
Get:17 http://deb.debian.org/debian bookworm-updates/non-free-firmware Sources [2,076 B]
Get:18 http://deb.debian.org/debian bookworm-updates/non-free-firmware amd64 Packages [616 B]
Get:19 http://deb.debian.org/debian bookworm-updates/non-free-firmware Translation-en [384 B]
Get:20 http://deb.debian.org/debian bookworm-updates/main amd64 Packages [2,468 B]
Get:21 http://deb.debian.org/debian bookworm-updates/main Translation-en [2,928 B]
Fetched 25.1 MB in 5s (4,866 kB/s)                                               
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
270 packages can be upgraded. Run 'apt list --upgradable' to see them.
N: Repository 'http://deb.debian.org/debian bookworm InRelease' changed its 'Version' value from '12.4' to '12.7'

Step 3 : Install the C compiler by using following command.

root@linuxhelp:~# apt install build-essential
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
build-essential is already the newest version (12.9).
The following packages were automatically installed and are no longer required:
  libc-ares2 libgrpc++1.51 libgrpc29 libprotoc32 libre2-9
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 270 not upgraded.

Step 4 : Write simple C program using nano editor by using following command.

root@linuxhelp:~# nano test.c
#include <stdio.h>

int main () {
	printf("linuxhelp gives good videos!\n");
	return 0;
}

Step 5 : Compile C program with the output name by using following command.

root@linuxhelp:~# gcc test.c -o ctest

Step 6 : Run compiled file to get output of the C program by using following command.

root@linuxhelp:~# ./ctest 
linuxhelp gives good videos!

Conclusion :

We have reached the end of this article. In this guide, we have walked you through the steps required to create simple C program on Debian 12. Your feedback is much welcome.

Tags:
jacob
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

1. What is C programming?

A

C is a high-level, general-purpose programming language developed in the early 1970s. It is known for its efficiency and control over system resources, making it ideal for system programming, embedded systems, and application development.

Q

2. What are the main features of C?

A

Efficiency: C allows for low-level memory manipulation and fine control over system resources.
Portability: C programs can run on various platforms with minimal changes.
Structured Programming: It supports functions, loops, and conditional statements for organized code.
Rich Library Support: The C Standard Library provides numerous built-in functions for tasks like input/output and string manipulation.

Q

3. How do you compile and run a C program?

A

To compile a C program, you typically use a compiler like GCC. For example:
Write your code in a file named program.c.
Open a terminal and run:
gcc program.c -o program

Execute the compiled program with:
./program

Q

4. What is the purpose of the main function?

A

The main function is the entry point of a C program. It is where execution begins. Every C program must have a main function, which returns an integer value to indicate the program's exit status (0 for success, non-zero for errors).

Q

5. What are pointers in C?

A

Pointers are variables that store the memory address of another variable. They are powerful features of C, allowing direct manipulation of memory, dynamic memory allocation, and efficient array handling. For example:
int a = 10;
int *p = &a; // p now points to the address of a

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Sebastian ?
How to change non required to required field in SuiteCRM Custom/Default Modules

How to change not required to the required field in SuiteCRM Custom/Default Modules?

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.