0% found this document useful (0 votes)
29 views6 pages

Key Features of C Programming Language

C is a widely used programming language that was developed by Dennis Ritchie to create system applications that directly interact with hardware. It is considered the base for many other languages. C programs are compiled into machine-independent object code that is linked and loaded for execution. The compilation process involves preprocessing, compiling, assembling, and linking source code files with library files to produce an executable program. A simple "Hello World" C program is provided as an example to demonstrate printing output using the printf() function.

Uploaded by

vishnu damuluri
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views6 pages

Key Features of C Programming Language

C is a widely used programming language that was developed by Dennis Ritchie to create system applications that directly interact with hardware. It is considered the base for many other languages. C programs are compiled into machine-independent object code that is linked and loaded for execution. The compilation process involves preprocessing, compiling, assembling, and linking source code files with library files to produce an executable program. A simple "Hello World" C program is provided as an example to demonstrate printing output using the printf() function.

Uploaded by

vishnu damuluri
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

C language

C language Tutorial with programming approach for beginners and professionals,


helps you to understand the C language tutorial easily. Our C tutorial explains each
topic with programs.

The C Language is developed by Dennis Ritchie for creating system applications that
directly interact with the hardware devices such as drivers, kernels, etc.

C programming is considered as the base for other programming languages, that is


why it is known as mother language.

Features of C Language

C is the widely used language. It provides many features that are given below.

1. Simple

2. Machine Independent or Portable

3. Mid-level programming language

4. structured programming language

5. Rich Library

6. Memory Management

7. Fast Speed
8. Pointers

9. Recursion

[Link]

First C Program
Before starting the abcd of C language, you need to learn how to write, compile and
run the first c program.

To write the first c program, open the C console and write the following code:

1. #include <stdio.h>    
2. int main(){    
3. printf("Hello C Language");    
4. return 0;   
5. }  

#include <stdio.h> includes the standard input output library functions. The


printf() function is defined in stdio.h .

int main() The main() function is the entry point of every program in c


language.

printf() The printf() function is used to print data on the console.

return 0 The return 0 statement, returns execution status to the OS. The 0 value is
used for successful execution and 1 for unsuccessful execution.

Compilation process in c
What is a compilation?
The compilation is a process of converting the source code into object code. It is
done with the help of the compiler. The compiler checks the source code for the
syntactical or structural errors, and if the source code is error-free, then it generates
the object code.

The following are the phases through which our program passes before being
transformed into an executable form:

o Preprocessor

o Compiler

o Assembler
o Linker

Preprocessor
The source code is the code which is written in a text editor and the source code file
is given an extension ".c". This source code is first passed to the preprocessor, and
then the preprocessor expands this code. After expanding the code, the expanded
code is passed to the compiler.

Compiler
The code which is expanded by the preprocessor is passed to the compiler. The
compiler converts this code into assembly code. Or we can say that the C compiler
converts the pre-processed code into assembly code.

Assembler
The assembly code is converted into object code by using an assembler. The name
of the object file generated by the assembler is the same as the source file. The
extension of the object file in DOS is '.obj,' and in UNIX, the extension is 'o'. If the
name of the source file is 'hello.c', then the name of the object file would be
'[Link]'.

Linker
Mainly, all the programs written in C use library functions. These library functions
are pre-compiled, and the object code of these library files is stored with '.lib' (or
'.a') extension. The main working of the linker is to combine the object code of
library files with the object code of our program. Sometimes the situation arises
when our program refers to the functions defined in other files; then linker plays a
very important role in this. It links the object code of these files to our program.
Therefore, we conclude that the job of the linker is to link the object code of our
program with the object code of the library files and other files. The output of the
linker is the executable file. The name of the executable file is the same as the
source file but differs only in their extensions. In DOS, the extension of the
executable file is '.exe', and in UNIX, the executable file can be named as '[Link]'. For
example, if we are using printf() function in a program, then the linker adds its
associated code in an output file.

Let's understand through an example.

hello.c

1. #include <stdio.h>  
2. int main()  
3. {  
4.     printf("Hello javaTpoint");  
5.     return 0;  
6. }  

Now, we will create a flow diagram of the above program:


In the above flow diagram, the following steps are taken to execute a
program:
o Firstly, the input file, i.e., hello.c, is passed to the preprocessor, and the
preprocessor converts the source code into expanded source code. The
extension of the expanded source code would be hello.i.
o The expanded source code is passed to the compiler, and the compiler
converts this expanded source code into assembly code. The extension of the
assembly code would be hello.s.
o This assembly code is then sent to the assembler, which converts the
assembly code into object code.
o After the creation of an object code, the linker creates the executable file. The
loader will then load the executable file for the execution.

Common questions

Powered by AI

The main purpose of a linker in the C programming language is to combine the object code of library files with the object code of the user's program. If the program references functions defined in other files, the linker links the object code of these files to the user's program. This process results in an executable file. The linker essentially ensures that all the necessary code, including pre-compiled library functions, is included in the program's final form .

Standard libraries in the C programming environment hold significant importance as they provide a set of precompiled and reusable functions that facilitate various common programming tasks, such as input/output operations, string handling, and mathematical computations. Using these libraries reduces the need for developers to implement complex functions from scratch, thereby improving development efficiency and program reliability. The standardization ensures code portability and makes sure that programs are robust and maintainable across different platforms .

The compilation process in C involves several steps: initially, the source code written in a text editor with a '.c' extension is processed by the preprocessor to generate expanded source code. This expanded code is converted into assembly code by the compiler. The assembler then transforms the assembly code into object code, typically having extensions like '.obj' in DOS or '.o' in UNIX. Finally, the linker combines the object code with any additional code from library files to create an executable file with extensions like '.exe' in DOS or usually 'a.out' in UNIX. This multi-step transformation ensures that the source code is correctly executed as a runnable program .

A C program passes through several phases from writing to execution: Firstly, the source code is written and is processed by the preprocessor, which expands the code into an 'expanded source code'. This code is then compiled into 'assembly code' by the compiler. The assembly code is transformed into 'object code' using the assembler. Finally, the linker combines this object code with any necessary library files to form an 'executable file'. The loader then loads this executable file into memory for execution, enabling the program to run on the machine .

The printf function is essential in C programs because it provides a means to output data to the console, which is crucial for user interaction and debugging. It operates as part of the standard input-output library, included via '#include <stdio.h>', and allows programmers to format strings that can include variables or constants. This makes it a versatile and powerful tool for displaying program results and progress to users .

C is referred to as the 'mother language' because it serves as the foundational basis for many other programming languages. C was developed to create system applications that directly interact with hardware devices, and its features like simplicity, portability, and efficiency have been emulated by numerous subsequent languages. As a mid-level language, it provides the ability to manipulate hardware directly while still supporting high-level programming constructs, making it a versatile tool for software development .

Memory management is an integral feature of the C programming language because it allows programmers to have direct control over the memory allocation and deallocation processes. C supports dynamic memory management through pointers and functions like malloc() and free(), which enable efficient use of memory and optimization of performance. This low-level access to memory is crucial for applications where performance and resource management are paramount, such as in systems programming or real-time applications .

The preprocessor in the C programming language handles the initial stage of the compilation process. It processes the source code, which entails expanding macros and including files as specified by the directives in the code. The preprocessor's operations result in an expanded source code that is then fed into the compiler for further translation into assembly code. This ensures that the program's code is prepared with all necessary components before true compilation begins .

In C programs, the 'main' function serves as the entry point, meaning that it is the first point of behavior that will be executed when the program runs. The significance of the 'main' function is that it is mandatory in C language programs; without it, the program would have no starting execution instruction, which would render it non-functional. The execution begins with 'main' and follows the control flow set by its statements, making it essential for program initialization and execution .

The C programming language offers several advantages over high-level programming languages: it provides portability, allowing programs to run on different hardware without modification; it supports a rich library that can be used to perform complex functions; and allows direct manipulation of hardware via pointers. Additionally, C offers fast execution speed and efficient memory management, enabling high-performance applications. As a mid-level language, it strikes a balance between higher-level abstraction and lower-level hardware control, which is not commonly found in purely high-level languages .

You might also like