INTRODUCTION TO C PROGRAMMING LANGUAGES

The C programming language, developed in 1972 by Dennis Ritchie at Bell Labs, is one of the most important and influential programming languages ​​in the history of computer science. It was designed as a tool for implementing the UNIX operating system, but it quickly spread to other areas thanks to its efficiency and versatility.
The main features of C include: The influence of C on modern languages ​​is enormous. C++, which was developed as an upgrade to C, introduces the concept of object-oriented programming, while languages ​​like Java and C# take many of the concepts of C but adapt them to work in modern applications. With its minimalist approach and proximity to hardware, C remains essential for any aspiring programmer. to understand the basics of programming and architecture of computer systems.

About the C programming language

C is a general programming language that is used for a wide range of applications from operating systems such as Windows and iOS for software that is used to create 3D movies.
C programming is very efficient. This is the main reason why he is very popular despite having more than 40 years. Standard C programs are portable. A source code written in one system runs in another operating system without any change. As said, it is a good language to start learning a program.Introducing to C programming language - example
Figure 1: Introducing to C programming language - example

Why use C?


C was initially used for system development work, particularly for programs that make up an operating system. C was adopted as a system development language because it produces code that runs almost as fast as code written in assembly language. Some examples of C usage include -

      Operating systems
      Compilers
      Assemblers
      Text editors
      Network drivers
      Modern programs
      Databases

Where the C programming language is used today

​The C language is still widely used in many areas of software development because of its efficiency, low level of abstraction, and closeness to hardware. Here are some key areas where C is used today:

1. Operating systems:
    - Many operating systems, including Unix, Linux, and parts of Windows, are written in C. The Linux kernel, for example, is mostly written in C.

2. Embedded systems:
    - C is dominant in the development of firmware and software for embedded systems, such as microcontrollers, sensors and various industrial and consumer electronics.

3. System software:
    - Compilers, interpreters, assemblers, and even some parts of the runtime environment of other programming languages ​​are often implemented in C because of its efficiency and control over hardware.

4. Development of databases:
    - Many databases, such as MySQL and PostgreSQL, are written in C, which allows them a high degree of performance and optimization.

5. Computer games and graphics:
    - C is used in the development of games and graphics engines, where speed is key. Many popular graphics engines such as Unity (uses C++) and Unreal Engine (uses C++) have components written in C.

6. Network protocols and security:
    - Many network protocols and security tools are implemented in C because of the need for high performance and direct access to memory and network devices.

7. High performance computers (HPC):
    - C is used in scientific research and numerical computing, where fast and efficient algorithm implementations are needed.

8. Development of drivers:
    - Hardware drivers are often written in C because they require direct access to hardware resources and efficient memory management.

9. Portability:
    - Programs written in C can be relatively easily ported between different platforms, which is useful for developing software that needs to run on different types of hardware.

Although newer languages ​​such as Python, Java, and C++ have taken over many areas of software development, C remains essential for situations where performance, hardware control, and efficiency are essential.

About this tutorial

This tutorial will explain the basics needed to create both simple and competitive tasks using the most popular algorithms: e.g. string sorting, binary search, Euclidean algorithm, etc.
The tutorial will also explain numerous examples created in both C and C++ variants of writing code. CodeBlock will be used as the development environment.
Given that every C program is also a C++ program, while the reverse is not true, i.e. not every C++ program is a C program, most solutions will be solved using the C++ variant in CodeBlock.

What is needed to create a C or C++ program?

In addition to the operating system, in order to be able to develop a C, as well as a C++ application, you need: The executable version can be created without installing the compiler on the local computer, by using the online version of the compiler: https://www.onlinegdb.com/online_c++_compiler.

A development tool for programming (optional), such as: dec c++, CodeBlock, VS Code, etc.
For the purposes of this tutorial, CodeBlock will be used, which can be downloaded from the website: https://www.codeblocks.org/downloads/

​C vs. C++. Advantages and disadvantages

C programming language

Advantages:

1. Simplicity:
   - C is a low-level language that is easier to learn and use because of its simple syntax and less functionality.

2. Efficiency:
   - Programs written in C have a high degree of performance and efficiency because they allow direct access to memory and hardware.

3. Portability:
   - C is a very portable language and can be used on almost any platform with minimal code changes.

4. Wide use:
   - C is the basis of many other programming languages, which makes learning those languages ​​easier. Many systems and applications are written in C, including operating systems and embedded systems.

Flaws

1. Limited support for object-oriented programming:
   - C does not have native support for object-oriented programming (OOP), which can make it difficult to organize and maintain larger projects.

2. Lack of abstraction:
   - C programmers must manage memory manually, which increases the risk of errors such as memory leaks and buffer overflows.

3. Lack of a standard library for modern functionalities:
   - C has a relatively limited standard library compared to more modern languages, which can require writing more code to implement certain functionalities.C++ programming language

Advantages

1. Support for Object Oriented Programming (OOP):
   - C++ adds support for classes, inheritance, polymorphism, and encapsulation, which allows for better code organization and modularity.

2. Standard Library (STL):
   - C++ comes with a rich standard library that includes containers, algorithms and functions for working with strings, which significantly speeds up software development.

3. Support for multiple paradigms:
   - In addition to OOP, C++ supports procedural, functional and generic programming, providing greater flexibility in software development.

4. RAII (Resource Acquisition Is Initialization):
   - C++ uses the RAII idiom for resource management, which facilitates proper management of memory and other resources.

Flaws:

1. Complexity:
   - C++ is a more complex language compared to C because of the additional functionalities and features, which can make it difficult to learn and use.

2. Higher compilation requirements:
   - Programs written in C++ often require more time to compile due to complex functionalities and rich standard library.

3. Potential for more complex errors:
   - Given that C++ provides many powerful tools, inadequate use of those tools can lead to complex errors that are more difficult to detect and correct.Conclusion: 

- C is ideal for systems and applications that require direct hardware access and maximum efficiency, such as operating systems, embedded systems, and hardware drivers.
- C++ is suitable for more complex applications that require better code organization and flexibility, such as graphics applications, game development, financial systems software, and other applications that can take advantage of object-oriented programming and a rich standard library.

The choice between C and C++ depends on the specific requirements of the project and the preferences of the programmer.For concrete examples and syntax of the C programming language, see the following pages of the tutorial, where the basic elements of the language are explained in detail.

​Versions of the C Programming Language

​The C programming language has undergone several key updates throughout its history, with each version introducing significant improvements, new features, and adaptations to modern programming needs.

C89/C90 (ANSI C)

C99

C11

C17

C23

​Reserved Keywords in C

Reserved keywords in C are predefined words with specific meanings that cannot be used as identifiers in your program.

The following table shows the evolution of reserved keywords across different versions of the C language:

Version Number of Reserved Keywords Example Keywords
C89/C90 32 auto, break, case, char
C99 37 inline, restrict, _Bool
C11 40 _Atomic, _Static_assert
C17 40 (same as C11)
C23 43+ (estimated) New additions under review

​How to Stay Updated?

Programmers who wish to stay current with the development of the C language should:
  1. Follow official standards published by ISO.
  2. Regularly consult the documentation for their compiler (e.g., GCC, Clang, MSVC).
  3. Learn about new features and keywords through courses and specialized guides.

Next
​Basics C and C++​​​>|