Introduction to C Programming Language
Introduction to C Programming Language
Programming Language
C is a powerful and versatile programming language that has been widely
used for system programming, application development, and scientific
computing since its creation in the 1970s. This introduction will guide you
through the fundamentals of C programming.
VG by Vishu Gupta
History of C
1 1972
C was created by Dennis Ritchie at Bell Labs as a systems
programming language to develop the Unix operating system.
2 1978
The first edition of the classic book "The C Programming
Language" by Brian Kernighan and Dennis Ritchie was
published, establishing C as a widely adopted language.
3 1989
The ANSI C standard was released, providing a formal
specification for the language and ensuring its portability
across different platforms.
Basic C Syntax and Structure
Functions Variables Syntax
C programs are built around functions, Variables are used to store data, and C C has a strict syntax, with the use of
which are blocks of code that perform supports a variety of data types like curly braces, semicolons, and specific
specific tasks. integers, floating-point numbers, and keywords to define the structure of the
characters. code.
Data Types and Variables in C
1 Primitive Data Types 2 Variable Declarations 3 Memory Allocation
C provides basic data types like int, Variables must be declared with a The size of each data type
float, double, char, and _Bool to specific data type before they can determines how much memory is
store different kinds of data. be used in the program. allocated to store the variable's
value.
Operators and Expressions in
C
Arithmetic Operators Logical Operators
C supports basic arithmetic C has logical operators like AND,
operations like addition, OR, and NOT to create complex
subtraction, multiplication, and conditional expressions.
division.
If-Else Statements
Conditional statements allow you to execute different blocks of code based
on the value of a condition.
Loops
Loops in C, such as for, while, and do-while, enable you to repeatedly execute a
block of code.
Switch Statements
The switch statement provides a concise way to handle multiple conditions
for a single variable.
Functions in C
Function Definition
1 Functions in C are defined with a return type, a name, and a set
of input parameters.
Function Call
2 Functions are called by their name, and arguments are passed
to the input parameters.
Return Values
3 Functions can return values back to the caller, which can be
used for further processing.
Memory Management in C
Static Memory Allocation Variables are assigned memory at
compile-time, with a fixed size.