Introduction To C
Introduction To C
Topperworld.in
Introduction to C
➢ Mother language
➢ System programming language
➢ Procedure-oriented programming language
➢ Structured programming language
➢ Mid-level programming language
Features of C Language
Here are some of the most important features of the C language:
Procedural Language
Fast and Efficient
Modularity
Statically Type
General-Purpose Language
Rich set of built-in Operators
Libraries with Rich Functions
Middle-Level Language
Portability
Easy to Extend
©Topperworld
C Programming
Why Learn C ?
©Topperworld
C Programming
Components of a C Program:
1. Header Files Inclusion – Line 1
[#include <stdio.h>]
⚫ 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.
Some of the C Header files:
©Topperworld
C Programming
[int main()]
[enclosed in {}]
4. Statement – Line 4
[printf(“Hello World”);]
©Topperworld
C Programming
[return 0;]
• 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.
C first Program
To begin with, the “Hello World” program is the first step towards learning any
programming language and also one of the simplest programs you will learn. All
one needs to do is display the message “Hello World” on the screen.
Let’s look at the program and try to understand the terminologies involved in it.
// main function -
// where the execution of program begins
int main()
{
printf("Hello World");
return 0;
}
©Topperworld
C Programming
➢ Compiling a C Program
hello.c
1. #include <stdio.h>
2. int main()
3. {
4. printf("Hello Topperworld");
5. return 0;
6. }
In the above example, 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.
©Topperworld
C Programming
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.
©Topperworld