This document provides an overview of the C programming language. It discusses that C was developed in 1972 by Dennis Ritchie at Bell Labs to write the UNIX operating system. Some key features of C mentioned include it being a procedural language, having a rich library, supporting pointers and recursion. The document also covers C program structure, data types, variables, constants, operators and escape sequences.
2. Introduction
• C is a general purpose programming language.
• It is a very popular and most widely used programming
language.
• Many of the important ideas of C are being brought
from the BPCL language.
• C programming is considered as the base for other
programming languages, that is why it is known as
mother language.
• C is strongly associated with UNIX, as it was
developed to write the UNIX operating system.
3. History
• C programming language was developed in 1972 by Dennis Ritchie at bell
laboratories of AT&T (American Telephone & Telegraph), located in the U.S.A.
• Dennis Ritchie is known as the founder of the c language.
• It was developed to overcome the problems of previous languages such as B, BCPL,
etc.
• Initially, C language was developed to be used in UNIX operating system. It inherits
many features of previous languages such as B and BCPL.
• Let's see the programming languages that were developed before C language.
Language Year Developed By
Algol 1960 International Group
BCPL 1967 Martin Richard
B 1970 Ken Thompson
Traditional C 1972 Dennis Ritchie
K & R C 1978 Kernighan & Dennis Ritchie
ANSI C 1989 ANSI Committee
ANSI/ISO C 1990 ISO Committee
C99 1999 Standardization Committee
4. Features
C is the widely used language. It provides many features that are
given below.
• Simple
• Procedural programming language
• structured programming language
• Rich Library
• Memory Management
• Fast Speed
• Pointers
• Recursion
5. Get started with C?
• Get Started With C
• To start using C, you need two things:
• A text editor, like Notepad, to write C code
• A compiler, like Turbo C++, Code Blocks, to translate the C code into a language
that the computer will understand.
• There are many text editors and compilers to choose from. Here, we will use
an IDE (see below).
• An IDE (Integrated Development Environment) is used to edit AND compile the
code.
• Note: Web-based IDE's can work as well, but functionality is limited.
• We will use Turbo C++ which we believe is a good place to start.
• You can find the latest version of Turbo C++
at https://developerinsider.co/download-turbo-c-for-windows-7-8-8-1-and-
windows-10-32-64-bit-full-screen/ . Download setup.exe file, which will install the
text editor with a compiler.
10. Before writing program in C, we need to have a basic
knowledge in the following.
Character set.
and
Tokens
11. The Character set of ‘C’
C language consist of some characters set, numbers and
some special symbols. The character set of C consist of all the
alphabets of English language. C consist of
Alphabets a to z, A to Z
Numeric 0,1 to 9
Special Symbols {,},[,],?,+,-,*,/,%,!,;,and more
. The
following different types of token are used in C
1) Identifiers 2)Keywords 3)Constants
4) Operators 5)Punctuation Symbols
12. Tokens
The words formed from the character set are building blocks of C and are sometimes
known as tokens. These tokens represent the individual entity of language
13. Identifiers
• A 'C' program consist of two types of elements , user
defined and system defined. Identifiers is nothing but a
name given to these elements.
• An identifier is a word used by a programmer to name a
variable , function, or label.
• identifiers consist of letters and digits, in any order,
except that the first character or label.
• Identifiers consist of letters and digits if any order,except
that the first charecter must be letter.
• Both Upper and lowercase letters can be used.
14. Keywords
• Keywords are nothing but system
defined identifiers.
• Keywords are reserved words of
the language.
• They have specific meaning in the
language and cannot be used by
the programmer as variable or
constant names
• C is case sensitive, it means these
must be used as it is
• 32 Keywords in C Programming
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while
15. Variables
• A variable is nothing but a name given to a storage area that our programs can manipulate. Each
variable in C has a specific type, which determines the size and layout of the variable's memory;
the range of values that can be stored within that memory; and the set of operations that can be
applied to the variable.
• The name of a variable can be composed of letters, digits, and the underscore character. It must
begin with either a letter or an underscore. Upper and lowercase letters are distinct because C is
case-sensitive. There are following basic variable types −
Type Description
• char Typically a single octet(one byte). This is an integer type.
• int The most natural size of integer for the machine.
• float A single-precision floating point value.
• double A double-precision floating point value.
• void Represents the absence of type.
20. C programming has wide range of operators to perform various
operations. For better understanding of operators, these operators
can be classified as:
• Arithmetic Operators
• Increment and Decrement Operators
• Assignment Operators
• Relational Operators
• Logical Operators
• Conditional Operators
• Bitwise Operators
• Special Operators
Operators
21. Arithmetic Operator
Arithmetic Operators
Arithmetic operators are used to perform common mathematical operations.
Operator Name Description Example Try it
+ Addition Adds together two values x + y Try it »
- Subtraction Subtracts one value from another x - y Try it »
* Multiplication Multiplies two values x * y Try it »
/ Division Divides one value by another x / y Try it »
% Modulus Returns the division remainder x % y Try it »
++ Increment Increases the value of a variable by 1 ++x Try it »
-- Decrement Decreases the value of a variable by 1 --x
22. Increment and Decrement Operator
The decrement (–) and increment (++) operators are special types of operators used in
programming languages to decrement and increment the value of the given variable by
1 (one), respectively.
Types of Increment and Decrement Operators in C
Following types of increment and decrement operators are found in the C language:
Prefix Increment operator
Prefix Decrement operator
Postfix Increment operator
Postfix Decrement operator
Increment Operators
We use increment operators in C to increment the given value of a variable by 1.
For instance,
int a = 1, b = 1;
++b; // valid
++3; // invalid – increment operator is operating on constant value
++(a+b); // invalid – increment operator is operating on expression
23. C Assignment Operators
• An assignment operator is used for assigning a
value to a variable. The most common
assignment operator is =
• Operator Example Same as
• = a = b a = b
• += a += b a = a+b
• -= a -= b a = a-b
• *= a *= b a = a*b
• /= a /= b a = a/b
• %= a %= b a = a%b
24. C Relational Operators
• A relational operator checks the relationship between
two operands. If the relation is true, it returns 1; if the
relation is false, it returns value 0.
• Relational operators are used in decision making and
loops.
Operator Meaning of Operator Example
• == Equal to 5 == 3 returns 0
• > Greater than 5 > 3 returns 1
• < Less than 5 < 3 returns 0
• != Not equal to 5 != 3 returns 1
• >= Greater than or equal to 5 >= 3 returns 1
• <= Less than or equal to 5 <= 3 return 0
25. Escape Sequences
Sometimes, it is necessary to use characters which cannot be typed or has special meaning in C
programming. For example: newline(enter), tab, question mark etc. In order to use these
characters, escape sequence is used.
• For example: n is used for newline. The backslash ( ) causes "escape" from the normal way the
characters are interpreted by the compiler.Escape
Sequences Character
• b Backspace
• f Form feed
• n Newline
• r Return
• t Horizontal tab
• v Vertical tab
• Backslash
• ' Single quotation mark
• " Double quotation mark
• ? Question mark
• 0 Null character