"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Introduction to C:)

Introduction to C:)

Published on 2024-08-19
Browse:400

History:

It was developed in 1972 by Dennis Ritchie at bell laboratories of AT&T (American Telephone & Telegraph), located in the U.S.A. It was developed after B,BCPL etc to overcome problems in that language. It was developed along with the UNIX operating system, and is strongly linked with UNIX operating system.

Introduction to C:)

Paradigms:

Procedural Programming

#include 

void greet() {
    printf("Hello, World!\n");
}

int main() {
    greet();
    return 0;
}

Low-level Programming

#include 

int main() {
    int x = 10;
    int *p = &x;
    printf("Value of x: %d\n", *p);
    return 0;
}

Performance

C is a compiled language. The source code written in C is compiled into machine code by a compiler. This machine code is platform-specific and can be executed directly by the computer's hardware, leading to high performance and efficiency.

How to Run a C File

1) Open Notepad and Type C Code: Write your C code in a text editor.
2) Save the File with a .c Extension: Save your file with a .c extension.
3) Run the Following Commands:

gcc filename.c -o outputname // Compilation
./outputname // Execution

Type System

Static Typing: Types are checked at compile-time, ensuring that type errors are caught early.

Strong Typing: Strict type rules are enforced, preventing type mismatches.

Manual Type Checking: The programmer is responsible for ensuring type correctness.

Abstraction

Low-Level Abstraction: C provides a low-level abstraction of the hardware, giving the programmer control over system resources and memory.

Important Facts

Manual Memory Management: C requires the programmer to manually allocate and deallocate memory using malloc, calloc, and free.
No Built-In Garbage Collection: C does not support automatic garbage collection, so memory management is the programmer's responsibility.

Usage

System Programming: Widely used for developing operating systems, compilers, and other system-level software.

Embedded Systems: Commonly used in the development of firmware and embedded software for devices such as microcontrollers and embedded systems.

Application Development: Used for developing performance-critical applications, such as video games and real-time systems.
Hardware Interface: Used to write drivers and interface with hardware components directly.

Scientific Computing: Utilized in scientific and engineering applications that require high performance.

Release Statement This article is reproduced at: https://dev.to/madgan95/introduction-to-c-4khc If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3