0% found this document useful (0 votes)
16 views9 pages

C Programming Language Reference Notes

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

C Programming Language Reference Notes

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

UNIT-1

Evolution of C Programming Language

1. Origin (1969 – 1973)


Developer: Dennis Ritchie at Bell Laboratories (AT&T).
Purpose: To create a programming language for the development of the UNIX operating
system.
Background: Before C, languages like BCPL and B existed. B was developed by Ken
Thompson but had limitations. C was created to overcome these limitations.
Key Features of Early C:
- Structured programming
- Efficient memory management
- Close to hardware, yet easier than assembly

2. K&R C (1978)
Authors: Brian Kernighan and Dennis Ritchie
Publication: 'The C Programming Language' (K&R Book)
Importance: K&R C became the de facto standard before formal standardization.
Improvements:
- Clear structure and guidelines
- Popularity in academics and industry

3. ANSI C (C89/C90) — 1989/1990


Standardized by: ANSI (C89), later ISO (C90)
Why: To define a unified, reliable version of C.
Key Features:
- Function prototypes
- Standard library functions
- Improved type safety
- Portability

4. C99 (1999)
Motivation: Modernize C with new features.
New Features:
- long long int, stdbool.h
- Inline functions
- Variable-length arrays
- // single-line comments
- stdint.h for fixed-width integers
- Enhanced floating-point support

5. C11 (2011)
Focus: Multi-threading and system-level programming.
Key Features:

Dr. VIJAYALAKSHMI.K/ Associate Professor, SSE


- <threads.h> for multi-threading
- Unicode support
- Atomic operations
- Safer functions
- Static assertions

6. C17 (2017 / 2018)


Purpose: Minor revision to fix bugs and clarify standards.
Features: No major additions, mostly clarifications and improvements.

7. C23 (Expected in 2024/2025)


Planned Updates:
- Improved Unicode handling
- Additional library functions
- Modern syntax conveniences
- Aim: Keep C relevant for modern applications.

History Details:

K&R C

Dennis Ritchie along with Brian Kernighan published the first edition of their book "The C
Programming Language". Popularly known as K&R (the initials of its authors), the book
served for many years as an informal specification of the language. The version of C that it
describes is commonly referred to as "K&R C". It is also referred to as C78.

Many of the features of C language introduced in K&R C are still the part of the language
ratified as late as in 2018. In early versions of C, only functions that return types other than
int must be declared if used before the function definition; functions used without prior
declaration were presumed to return type int.

C compilers by AT&T and other vendors supported several features added to the K&R C
language. Although C started gaining popularity, there was a lack of uniformity in
implementation. Therefore, it was felt that the language specifications must be standardized.

ANSI C

In the 1980s, the American National Standards Institute (ANSI) began working on a formal
standard for the C language. This led to the development of ANSI C, which was standardized
in 1989. ANSI C introduced several new features and clarified ambiguities present in earlier
versions of the language.

C89/C90

The ANSI C standard was adopted internationally and became known as C89 (or C90,
depending on the year of ratification). It served as the basis for compilers and development
tools for many years.

C99

Dr. VIJAYALAKSHMI.K/ Associate Professor, SSE


In 1999, the ISO/IEC approved an updated version of the C standard known as C99. The C
standard was further revised in the late 1990s.

C99 introduced new features, including inline functions, several new data types such as a
complex type to represent complex numbers, and variable-length arrays etc. It also added
support for C++ style one-line comments beginning with //.

C11

C11, published in 2011, is another major revision of the C standard. The C11 standard adds
new features to C and the library and introduced features such as multi-threading support,
anonymous structures and unions, and improved Unicode support.

It includes type generic macros, anonymous structures, improved Unicode support, atomic
operations, multi-threading, and bounds-checked functions. It has an improved compatibility
with C++.

C17

The C17 standard has been published in June 2018. C17 is the current standard for the C
programming language. No new features have been introduced with this standard revision.
It only performs certain technical corrections, and clarifications to defects in C11.

C18

The most recent version of the C standard, C18, was published in 2018. It includes minor
revisions and bug fixes compared to C11.

C23

C23 is the informal name for the next major C language standard revision, expected to be
published in 2024. 14 new keywords are expected to be introduced in this revision.

C has remained popular over time because to its simplicity, efficiency, and versatility. It has
been used to create a diverse spectrum of software including operating systems, embedded
systems, applications, and games. C's syntax and semantics have also impacted different
modern programming languages such as C++, Java, and Python.

STEP BY STEP COMPILATION PROCESS WITH DIAGRAM:

The compilation is the process of converting the source code of the C language into machine
code. As C is a mid-level language, it needs a compiler to convert it into an executable code so
that the program can be run on our machine.

Simply can defined as “The c compilation process converts the source code taken as input
into the object code or machine code.”

Dr. VIJAYALAKSHMI.K/ Associate Professor, SSE


The compilation process can be divided into four steps, i.e.,

Pre-processing,

Compiling,

Assembling, and

Linking.

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

Dr. VIJAYALAKSHMI.K/ Associate Professor, SSE


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 ‘hello.obj’.

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 ‘a.out’. For example, if we are using
printf() function in a program, then the linker adds its associated code in an output file.

DECISION MAKING STATEMENT:

Decision making is about deciding the order of execution of statements based on certain
conditions or repeat a group of statements until certain specified conditions are met.

1. if Statement
Used for: To execute a block of code when a specific condition is true.

Syntax:
if (condition) {
// statements to execute if condition is true
}

Example:

#include <stdio.h>

int main() {

int num = 5;

if (num > 0) {

printf("Number is positive."); }

return 0;}

Dr. VIJAYALAKSHMI.K/ Associate Professor, SSE


OUTPUT:
Number is positive

2. if-else Statement
Used for: To execute one block if true, another block if false.

Syntax:
if (condition) {
// statements if true
} else {
// statements if false
}

Example:
#include <stdio.h>

int main() {

int num = -3;

if (num > 0) {

printf("Number is positive.");

} else {

printf("Number is negative.");

return 0;

OUTPUT:

Number is negative.

3. nested if Statement
Used for: To check multiple conditions where one is inside another.

Syntax:
if (condition1) {
if (condition2) {
// statements if both conditions are true
}
}

Dr. VIJAYALAKSHMI.K/ Associate Professor, SSE


Example:

#include <stdio.h>

int main() {

int num = 10;

if (num > 0) {

if (num % 2 == 0) {

printf("Positive and even.");

return 0;

OUTPUT:
Positive and even.

4. else-if Ladder
Used for: Checking multiple conditions sequentially.

Syntax:
if (condition1) {
// statements
} else if (condition2) {
// statements
} else {
// statements if none are true
}

Example:

#include <stdio.h>

int main() {

int marks = 75;

if (marks >= 90) {

printf("Grade A");

} else if (marks >= 75) {

Dr. VIJAYALAKSHMI.K/ Associate Professor, SSE


printf("Grade B");

} else if (marks >= 50) {

printf("Grade C");

} else {

printf("Fail");

return 0;

OUTPUT:
Grade B

5. switch Statement
Used for: Selecting a block to execute from multiple options based on a variable value.

Syntax:
switch (expression) {
case value1:
// statements
break;
case value2:
// statements
break;
default:
// statements
}

Example:
#include<stdio.h>

int main()

int day = 3;
switch (day) {
case 1: printf("Monday"); break;
case 2: printf("Tuesday"); break;
case 3: printf("Wednesday"); break;
default: printf("Invalid day");
}

Dr. VIJAYALAKSHMI.K/ Associate Professor, SSE


return 0;

OUTPUT:
Wednesday

Dr. VIJAYALAKSHMI.K/ Associate Professor, SSE

You might also like