2.4 C Programing Language
2.4 C Programing Language
Devyani Soni
Department of Computer science and technology
C language
It is a very popular language, despite being old. The main reason for
its popularity is because it is a fundamental language in the field of
computer science.
During the compilation process, the compiler checks for all the compilation
errors. If the online C compiler gives no error, then the hello.s is taken as input
and turned into hello.o by the assembler in the next phase.
This file contains machine-level instructions. At this phase, only existing code
is converted into machine language, and the function calls are not resolved.
Since the object file is not executable, the process is transferred to the linker,
which ultimately produces a .exe file.
4. Linking the Program with functions from the C library: This is the final
phase, in which all of the function calls are linked to their definitions. Linker
knows where all these functions are implemented. The linker performs
additional work and adds more code to our programe that is required when it
starts and stops. Setting up the environment, for example, requires a code, as
does sending command-line inputs. The linker connects the object code of our
programme file to the C library functions, resulting in an.exe file, hello.exe,
which is an executable file, will be created here.
The basic structure of a C program is divided into 6 parts which makes it easy
to read, modify, document, and understand in a particular format.
All the header files of the program will be declared in the preprocessor
section of the program. Header files help us to access other’s improved code
into our code. A copy of these multiple files is inserted into our program
before the process of compilation.
Example:
#include<stdio.h>
#include<math.h>
3. Definition
Preprocessors are the programs that process our source code before the
process of compilation. There are multiple steps which are involved in the
writing and execution of the program. Preprocessor directives start with the
‘#’ symbol.
Example:
Example:
Every C program must have a main function. The main() function of the
program is written in this section. Operations like declaration and execution
are performed inside the curly braces of the main program. The return type
of the main() function can be int as well as void too. void() main tells the
compiler that the program will not return any value. The int main() tells the
compiler that the program will return an integer value.
Example:
void main()
or
int main()
6. Sub Programs
User-defined functions are called in this section of the program. The control
of the program is shifted to the called function whenever they are called from
the main or outside the main() function. These are specified as per the
requirements of the programmer.
Example:
Both BCPL and B programming languages were typeless. After that, C was
developed using BCPL and B by Dennis Ritchie at the Bell lab in 1972.
Faster Running Speed: Any developer who wants to execute any program or
application quickly relies on the C language for the fast execution cycle. As C
uses fewer instructions, it executes faster than any other programming
language, such as Java, Ruby, PHP, etc.
Compile Time Speed Accuracy: The C compiler is very efficient; it quickly
produces your code into machine-level code. Lakhs of lines of code can be
compiled at one instance of a time and put in front of a developer in a couple
of seconds. The C compiler makes the code more efficient for faster and
optimized execution. as the compile time is high in the c language, the error
detections are also at high-speed rates.
C programming has a wide range of applications across various domains. Here are
some notable areas where C is commonly used:
2. Application Software
C is used to build a variety of application software, such as text editors,
compilers, and databases. It provides the necessary tools and efficiency to create
robust and performance-critical applications.
3. Game Development
Many video games and game engines are developed in C or C++. These languages
offer the performance and control needed for real-time rendering and complex
game logic.
4. Embedded Systems
C is widely used in the development of embedded systems found in consumer
electronics, automotive systems, medical devices, and more. Its ability to work
with limited resources makes it a preferred choice in this domain.
5. Scientific Computing
C is used in scientific research and computational modeling due to its efficiency
in handling complex calculations. Researchers often use C for simulations, data
analysis, and scientific programming.
6. Web Development (Backend)
Although higher-level languages like Python and JavaScript dominate web
development, C can be used for developing web server software and optimizing
critical components of web applications.