C Language Introduction
C Language Introduction
#include <stdio.h>
int main() {
int a = 10;
printf("%d", a);
return 0;
}
Components of a C Program:
The first and foremost component is the inclusion of the Header files in a C program. A header file is
a file with extension .h which contains C function declarations and macro definitions to be shared
between several source files. All lines that start with # are processed by a preprocessor which is a
program invoked by the compiler. In the above example, the preprocessor copies the preprocessed
code of stdio.h to our file. The .h files are called header files in C.
stdlib.h – Defines numeric conversion functions, pseudo-random number generator, and memory
allocation
The next part of a C program is to declare the main() function. It is the entry point of a C program
and the execution typically begins with the first line of the main(). The empty brackets indicate that
the main doesn’t take any parameter (See this for more details). The int that was written before the
main indicates the return type of main(). The value returned by the main indicates the status of
program termination. See this post for more details on the return type.
Statements are the instructions given to the compiler. In C, a statement is always terminated by a
semicolon (;). In this particular case, we use printf() function to instruct the compiler to display
“Hello World” text on the screen.
The last part of any C function is the return statement. The return statement refers to the return
values from a function. This return statement and return value depend upon the return type of the
function. The return statement in our program returns the value from main(). The returned value
may be used by an operating system to know the termination status of your program. The value 0
typically means successful termination.
Windows: There are many free IDEs available for developing programs in C like Code Blocks and Dev-
CPP. IDEs provide us with an environment to develop code, compile it and finally execute it. We
strongly recommend Code Blocks.
Linux: GCC compiler comes bundled with Linux which compiles C programs and generates
executables for us to run. Code Blocks can also be used with Linux.
macOS: macOS already has a built-in text editor where you can just simply write the code and save it
with a “.c” extension.
Application of C
Operating systems: C is widely used for developing operating systems such as Unix, Linux, and
Windows.
System software: C is used for developing system software such as device drivers, compilers, and
assemblers.
Networking: C is widely used for developing networking applications such as web servers, network
protocols, and network drivers.
Database systems: C is used for developing database systems such as Oracle, MySQL, and
PostgreSQL.
Gaming: C is often used for developing computer games due to its ability to handle low-level
hardware interactions.
Artificial Intelligence: C is used for developing artificial intelligence and machine learning applications
such as neural networks and deep learning algorithms.
Scientific applications: C is used for developing scientific applications such as simulation software
and numerical analysis tools.
Financial applications: C is used for developing financial applications such as stock market analysis
and trading systems.