SlideShare a Scribd company logo
1 of 25
1.1 History of C Language
Language Name Year of development Description
ALGOL 60 1960 TOO ABSTRACT AND TOO SHORT
CPL 1963 COMBINED P.L
BCPL 1967 USED TO WRITE SYSTEM S/W.
WAS NOT SO POWERFUL.
B 1970 MACHINE DEPENDENT
C 1972 GENERAL PURPOSE,COMPILED,
STRUCTURED P.L, WITH UNIX O.S
- ‘C’ LANGUAGE WAS DEVELOPED BY ‘DENNIS RITCHIE’ AT AT &T BELL LABORATORY IN 1972.
Vijayalaxmi D Wakode
Importance of C
1. It is robust language whose rich set of built in functions and operators
can be used to write any complex program.
2. The language is very well suited from writing both system s/w and
business package. We can also write compilers .
3. We can also write structural programs using C language.
Character Set of C
LETTERS A-Z, a-z
DIGITS 0-9
SPECIAL CHARACTER _ ,! , etc.
WHITE SPACES tab , enter , etc.
The white spaces are ignored by compiler unless they are part of strings.
Vijayalaxmi D Wakode
1.2 TOKENS IN C
• To form a program i.e. set of executable statement , we need grammar.
Like all language , C language also has its own rules and grammar known
as syntactic rules / syntax.
• The smallest individual unit in a program is known as ‘Token’.
e.g. int,
char, float,
do , etc
Num , hello,
world, etc
e.g.
10,5, 90.11,
etc
e.g.
+ , - , * , %,/,
etc
e.g. “Hello
This is 1st
lecture”
e.g.
{},[], etc
Vijayalaxmi D Wakode
i) Keywords
• A keyword is a reserved word whose meaning can’t be changed by user.
• Keyword serves as a basic building block for program design and
development. The keywords must be written in ‘Lower Case’ , they have
predefined meaning .
• The C language consists of 32 keywords.
Table 1.1 Keywords in ANSI C Vijayalaxmi D Wakode
ii)Identifier
• The words other than the keywords that are used in C program are
known as ‘Identifiers’. These are the names that can be given to
various program elements as variable, function, etc.
• Identifier is user defined name.
• The language identifies only 1st 32 characters as the identifiers.
Naming rules for identifier
a) First letter of identifier should not start with a digit
b) Upper case and lower case letters are different
c) The keyword name can’t be identifier
d) White spaces and special symbols except underscore( _ ) are not allowed
Vijayalaxmi D Wakode
iii) Constants
• In C language , the constants are referred to fixed values that don’t change
during program execution.
Figure 1.1: Types of constants in C Vijayalaxmi D Wakode
a)Integer Constants
• Decimal Integers : consists of a set of digits 0 to 9 preceded by an optional + or –
sign. Spaces, commas and non digit characters are not permitted between digits.
e.g. 12, -44 , 787878
• Octal Integers : consists of any combination of digits from 0 to 7 with prefix O.
e.g. O26, O22 , O7
• Hexadecimal Integers : it is preceded by OX or Ox, they may contain alphabets
from A to F(10-15) or a to f(10-15)
• The quantities that are represented by numbers containing fractional parts are
called real or floating point constants. These quantities are represented by
numbers containing fractional parts like 98.72.
e.g. 0.0023, -9.8
b)Real Constants
Vijayalaxmi D Wakode
c) single character constants
• These constants are of a single character may be an alphabet, digit or special
symbol that is enclosed in a pairs of single quotation marks .
e.g. ‘x’ , ‘12’ , ‘ . ’ , etc.
• These consists of the sequence of characters that are enclosed within a pairs of a
double quotation marks.
e.g. “Introduction of C” , “XYZ 123 ” , etc.
• In C , every string is terminated by ‘0’ . It is null character that is automatically
added to the string by the compiler . It is backslash character constant. These are
also known as escape sequence character .
d) string character constants
Vijayalaxmi D Wakode
Escape sequence characters
• Backslash used in front of these characters tells the compiler to
escape from regular behavior and perform the desired function.
• List of the other such characters is as shown
n new line
b backspace
t horizontal space
o null character
r carriage return
• The constants can be defined in 2 ways in program.
-we can give a direct value that is used as constant. E.g. int a=10.
-we can use #define preprocessor directive. E.g. #define PI 3.14
Vijayalaxmi D Wakode
iv)Operator
• A operator is defined as a symbol that tells the computer to perform
certain mathematical or logical manipulation.
• These are basically used to manipulate data .
• C provides a rich set of built in operators.
Vijayalaxmi D Wakode
a) Arithmetic Operator
• The C language supports various different arithmetic operators as +,-,/,*,%.
The % is known as modulus operator used to find remainder of an expression.
Integer Arithmetic
• An arithmetic operation performed on 2 whole numbers/ integers . It always
gives an integer result. In integer division the fractional part is truncated.
Floating point Arithmetic
• An arithmetic operation performed on 2 real / fractional numbers. It results
can be truncated according to the properties requirement. The remainder
operator (%) is not applicable for floating point arithmetic operands.
Mixed mode Arithmetic
• An arithmetic operation performed on 1 of real operands and another integer
operand. Its result is always real.
Vijayalaxmi D Wakode
b)Comparison Operator
• These operators are also known as relational operator. These are used to
compare 2 quantities. The value of relational expression is either 0/1. If
expression is true then 1 and 0 if its false
• Syntax : exp1 relational operator exp2. e.g. -90 > 0 false(0), 11> 7+2 true(1)
• Relational operator are used in decision making statements in C language.
symbols meaning
< Less than
<= Less than equal to
> Greater than
>= Greater than equal to
== Equal to
!= Not equal to
Vijayalaxmi D Wakode
c) Logical Operator
• The language supports 3 kinds of logical operator. These are basically used
when we want to use more than 1 condition and make certain decision.
i)Logical AND (&&) ii)Logical OR(||)
iii) Logical NOT(!)
A B o/p : A && B
0 0 0
0 1 0
1 0 0
1 1 1
A B o/p : A|| B
0 0 0
0 1 1
1 0 1
1 1 1
A o/p: !A
0 1
1 0
Vijayalaxmi D Wakode
v) Assignment Operator
• These are used to assign the result of an expression to a variable / it
can also be used to assign value to a variable.
• In case of assignment operator L.H.S must be a variable but R.H.S can
be expression or any constant value.
e.g. A = 2, x = A + 3
• C language also supports set of short hand assignment operator .
Operator Stmt with simple assign
operator
Stmt with shorthand
property
+= a=a+1 a+=1
-= a=a-1 a-=1
*= a=a*1 a*=1
/= a=a/1 a/=1
%= a=a%1 a%=1
Vijayalaxmi D Wakode
v) Unary Operator
Vijayalaxmi D Wakode
vi)Conditional Operator
• Conditional operator operates 3 conditions, hence also known as
ternary operator.
Syntax : expr1 ? expr2 : expr3;
e.g. (5>10)? printf(“5”); : printf(“10”);
• Expr1 is evaluated first. Its value is either true or false . If it is true the
expr2 is evaluated and this becomes value of complete expr. If expr1
is false, then expr3 is evaluated and this becomes the value of
complete expr. Only 1 of the expr’s i.e expr2/ expr3 will be evaluated
but not both.
• Conditional operator is short form of if…else structure.
Vijayalaxmi D Wakode
vii)Bitwise Operator
• C language also supports various bitwise operator that operates at bit level.
These are used to test bits them in left / right.
• The o/p of bitwise AND is 1 if all the corresponding bits of all operands is 1.
• The o/p of bitwise OR is 1 if at least one corresponding bits of all operands is 1.
• The o/p of bitwise XOR is 1 if the corresponding bits of 2 operands are opposite.
• Bitwise complement operator is an unary operator. It changes 1 to 0(condition).
operator meaning
& Bitwise and
| Bitwise or
~ Complement
^ Bitwise exclusive or
<< Shift left
>> Shift right
Vijayalaxmi D Wakode
viii) Special Operator
• C language also supports some special operators as comma, sizeof(),
pointer operator (*), member selection operator( . )
i) comma operator :
It is used to separate variables.
e.g. int a,b,c;
ii) sizeof operator :
The sizeof is a compile time operator that returns the numbers of
bytes the operand occupies. The operand may be a variable , constant or
datatype qualifier.
e.g. int x,y;
y=sizeof(x);
o/p: y = 2 Vijayalaxmi D Wakode
1.3 Data Types in C
• Datatype means type of data which we are going to give to computer for
processing. It basically used to calculate the memory requirement.
fig. 1.2. Data types in C
Vijayalaxmi D Wakode
Primary Data Types
These are the built in and fundamental data types .
Integers are whole numbers i.e. numbers without decimal point. All these data types
short int, int, long int have signed & unsigned forms. Unsigned numbers are always
positive.
Floating point numbers are real numbers. It has 6 digits of precision. These numbers
are denoted by keyword float. When accuracy of floating point number
is insufficient , we use double keyword, it has 14 digits precision. To extend precision
further , we use long double.
It is used to specify type of function. When function does not return any value and if
there is empty parameter list
It is declared using keyword char. It stores single character item.
Integer Type
Vijayalaxmi D Wakode
Floating Point Type
Void Type
Character Type
Storage space requirement
Type
Size Range
short int 8 bits(1 byte) -128 to 127
int or signed int 16 bits(2 bytes) -32768 to 32767
Unsigned int 16 bits(2 bytes) 0 to 65535
Long int 32 bits(4 bytes) -2,147,483,648 to 2,147,483,648
Unsigned long int 32 bits(4 bytes) 0 to 4,294,967,295
Float 32 bits(4 bytes) 2^32
Double 64 bits(8 bytes) 2^64
Long double 80 bits(10 bytes) 2^80
Char 8 bits(1 byte) -128 to 127
Vijayalaxmi D Wakode
Table 1.2 Primary data types in C
1.4 Variables in C
• A variable is used to store data. It tells compiler variable name and data type of
variable.
Declaration : datatype identifier;
e.g. int x,y,z;
Converting lower type to higher type and vice versa, is known as type conversion.
Lower type is automatically converted into higher type
It is the process of local conversion. Its also known as type casting
Syntax : (type name) expression;
Type name is standard data type in c
Vijayalaxmi D Wakode
Type Conversion
a) Implicit Conversion
b)Explicit Conversion
1.5 Input and Output in C
Vijayalaxmi D Wakode
fig.1.3 input/output function in C
Format specifiers
symbol use
%d integer
%f Float value
%c Character value
%s String value
%u Unsigned integer value
%ld Long int
Vijayalaxmi D Wakode
1.6 Structure of C Program
Documentation Section
Link Section
Definition Section
Global Declaration Section
Main()
{
Declaration Part;
Executable Part;
}
Subprogram Section :
Function 1, Function 2, Function 3 Vijayalaxmi D Wakode

More Related Content

What's hot (20)

Introduction to c++ ppt 1
Introduction to c++ ppt 1Introduction to c++ ppt 1
Introduction to c++ ppt 1
 
C language unit-1
C language unit-1C language unit-1
C language unit-1
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
 
C functions
C functionsC functions
C functions
 
C Token’s
C Token’sC Token’s
C Token’s
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Features of c language 1
Features of c language 1Features of c language 1
Features of c language 1
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
 
Conditional operators
Conditional operatorsConditional operators
Conditional operators
 
What is keyword in c programming
What is keyword in c programmingWhat is keyword in c programming
What is keyword in c programming
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Functions in C
Functions in CFunctions in C
Functions in C
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Basics Of C Programming For Beginners In Easiest Way
Basics Of C Programming For Beginners In Easiest WayBasics Of C Programming For Beginners In Easiest Way
Basics Of C Programming For Beginners In Easiest Way
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 

Viewers also liked

INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGAbhishek Dwivedi
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programmingavikdhupar
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointJavaTpoint.Com
 
Introduction of c_language
Introduction of c_languageIntroduction of c_language
Introduction of c_languageSINGH PROJECTS
 
programming c language.
programming c language. programming c language.
programming c language. Abdul Rehman
 
Oops And C++ Fundamentals
Oops And C++ FundamentalsOops And C++ Fundamentals
Oops And C++ FundamentalsSubhasis Nayak
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming LanguageArkadeep Dey
 
Lecture 2 history_of_c
Lecture 2 history_of_cLecture 2 history_of_c
Lecture 2 history_of_ceShikshak
 
C++ history session 00 history
C++ history session 00   historyC++ history session 00   history
C++ history session 00 historyArun Prakash
 
Victorian Crisis in Tennyson’s "Lotos Eaters"
Victorian Crisis in Tennyson’s "Lotos Eaters"Victorian Crisis in Tennyson’s "Lotos Eaters"
Victorian Crisis in Tennyson’s "Lotos Eaters"Nazmul Hetfield Batchu
 
Overview of c language
Overview of c languageOverview of c language
Overview of c languageshalini392
 
Array in c language
Array in c languageArray in c language
Array in c languagehome
 
History Of Computer
History Of ComputerHistory Of Computer
History Of Computerguest420b9d
 
Generations of computer
Generations of computerGenerations of computer
Generations of computerJatin Jindal
 
Learning c - An extensive guide to learn the C Language
Learning c - An extensive guide to learn the C LanguageLearning c - An extensive guide to learn the C Language
Learning c - An extensive guide to learn the C LanguageAbhishek Dwivedi
 

Viewers also liked (20)

INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
 
Introduction of c_language
Introduction of c_languageIntroduction of c_language
Introduction of c_language
 
programming c language.
programming c language. programming c language.
programming c language.
 
Oops And C++ Fundamentals
Oops And C++ FundamentalsOops And C++ Fundamentals
Oops And C++ Fundamentals
 
Uses of computers
Uses of computersUses of computers
Uses of computers
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
 
Lecture 2 history_of_c
Lecture 2 history_of_cLecture 2 history_of_c
Lecture 2 history_of_c
 
C++ history session 00 history
C++ history session 00   historyC++ history session 00   history
C++ history session 00 history
 
C vs c++
C vs c++C vs c++
C vs c++
 
Victorian Crisis in Tennyson’s "Lotos Eaters"
Victorian Crisis in Tennyson’s "Lotos Eaters"Victorian Crisis in Tennyson’s "Lotos Eaters"
Victorian Crisis in Tennyson’s "Lotos Eaters"
 
Overview of c language
Overview of c languageOverview of c language
Overview of c language
 
Computer History
Computer HistoryComputer History
Computer History
 
Array in c language
Array in c languageArray in c language
Array in c language
 
C language ppt
C language pptC language ppt
C language ppt
 
History Of Computer
History Of ComputerHistory Of Computer
History Of Computer
 
Generations of computer
Generations of computerGenerations of computer
Generations of computer
 
Learning c - An extensive guide to learn the C Language
Learning c - An extensive guide to learn the C LanguageLearning c - An extensive guide to learn the C Language
Learning c - An extensive guide to learn the C Language
 
GENERATION OF COMPUTERS.
GENERATION OF COMPUTERS.GENERATION OF COMPUTERS.
GENERATION OF COMPUTERS.
 

Similar to fundamentals of c

M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageDr.Florence Dayana
 
Chapter 2: Elementary Programming
Chapter 2: Elementary ProgrammingChapter 2: Elementary Programming
Chapter 2: Elementary ProgrammingEric Chou
 
C language
C languageC language
C languageSMS2007
 
Msc prev completed
Msc prev completedMsc prev completed
Msc prev completedmshoaib15
 
Msc prev updated
Msc prev updatedMsc prev updated
Msc prev updatedmshoaib15
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introductionnikshaikh786
 
Basic C Programming language
Basic C Programming languageBasic C Programming language
Basic C Programming languageAbhishek Soni
 
C presentation book
C presentation bookC presentation book
C presentation bookkrunal1210
 
C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#Dr.Neeraj Kumar Pandey
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.pptTanuGohel
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.pptMEHALAS3
 
Basics of C (1).ppt
Basics of C (1).pptBasics of C (1).ppt
Basics of C (1).pptSteveIrwin25
 

Similar to fundamentals of c (20)

M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C Language
 
Chapter 2: Elementary Programming
Chapter 2: Elementary ProgrammingChapter 2: Elementary Programming
Chapter 2: Elementary Programming
 
C language
C languageC language
C language
 
Msc prev completed
Msc prev completedMsc prev completed
Msc prev completed
 
Msc prev updated
Msc prev updatedMsc prev updated
Msc prev updated
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
 
Basic C Programming language
Basic C Programming languageBasic C Programming language
Basic C Programming language
 
All C ppt.ppt
All C ppt.pptAll C ppt.ppt
All C ppt.ppt
 
C presentation book
C presentation bookC presentation book
C presentation book
 
C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#
 
C programming.pdf
C programming.pdfC programming.pdf
C programming.pdf
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
#Code2 create c++ for beginners
#Code2 create  c++ for beginners #Code2 create  c++ for beginners
#Code2 create c++ for beginners
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Funa-C.ppt
Funa-C.pptFuna-C.ppt
Funa-C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C (1).ppt
Basics of C (1).pptBasics of C (1).ppt
Basics of C (1).ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 

Recently uploaded

Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 

Recently uploaded (20)

Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 

fundamentals of c

  • 1. 1.1 History of C Language Language Name Year of development Description ALGOL 60 1960 TOO ABSTRACT AND TOO SHORT CPL 1963 COMBINED P.L BCPL 1967 USED TO WRITE SYSTEM S/W. WAS NOT SO POWERFUL. B 1970 MACHINE DEPENDENT C 1972 GENERAL PURPOSE,COMPILED, STRUCTURED P.L, WITH UNIX O.S - ‘C’ LANGUAGE WAS DEVELOPED BY ‘DENNIS RITCHIE’ AT AT &T BELL LABORATORY IN 1972. Vijayalaxmi D Wakode
  • 2. Importance of C 1. It is robust language whose rich set of built in functions and operators can be used to write any complex program. 2. The language is very well suited from writing both system s/w and business package. We can also write compilers . 3. We can also write structural programs using C language. Character Set of C LETTERS A-Z, a-z DIGITS 0-9 SPECIAL CHARACTER _ ,! , etc. WHITE SPACES tab , enter , etc. The white spaces are ignored by compiler unless they are part of strings. Vijayalaxmi D Wakode
  • 3. 1.2 TOKENS IN C • To form a program i.e. set of executable statement , we need grammar. Like all language , C language also has its own rules and grammar known as syntactic rules / syntax. • The smallest individual unit in a program is known as ‘Token’. e.g. int, char, float, do , etc Num , hello, world, etc e.g. 10,5, 90.11, etc e.g. + , - , * , %,/, etc e.g. “Hello This is 1st lecture” e.g. {},[], etc Vijayalaxmi D Wakode
  • 4. i) Keywords • A keyword is a reserved word whose meaning can’t be changed by user. • Keyword serves as a basic building block for program design and development. The keywords must be written in ‘Lower Case’ , they have predefined meaning . • The C language consists of 32 keywords. Table 1.1 Keywords in ANSI C Vijayalaxmi D Wakode
  • 5. ii)Identifier • The words other than the keywords that are used in C program are known as ‘Identifiers’. These are the names that can be given to various program elements as variable, function, etc. • Identifier is user defined name. • The language identifies only 1st 32 characters as the identifiers. Naming rules for identifier a) First letter of identifier should not start with a digit b) Upper case and lower case letters are different c) The keyword name can’t be identifier d) White spaces and special symbols except underscore( _ ) are not allowed Vijayalaxmi D Wakode
  • 6. iii) Constants • In C language , the constants are referred to fixed values that don’t change during program execution. Figure 1.1: Types of constants in C Vijayalaxmi D Wakode
  • 7. a)Integer Constants • Decimal Integers : consists of a set of digits 0 to 9 preceded by an optional + or – sign. Spaces, commas and non digit characters are not permitted between digits. e.g. 12, -44 , 787878 • Octal Integers : consists of any combination of digits from 0 to 7 with prefix O. e.g. O26, O22 , O7 • Hexadecimal Integers : it is preceded by OX or Ox, they may contain alphabets from A to F(10-15) or a to f(10-15) • The quantities that are represented by numbers containing fractional parts are called real or floating point constants. These quantities are represented by numbers containing fractional parts like 98.72. e.g. 0.0023, -9.8 b)Real Constants Vijayalaxmi D Wakode
  • 8. c) single character constants • These constants are of a single character may be an alphabet, digit or special symbol that is enclosed in a pairs of single quotation marks . e.g. ‘x’ , ‘12’ , ‘ . ’ , etc. • These consists of the sequence of characters that are enclosed within a pairs of a double quotation marks. e.g. “Introduction of C” , “XYZ 123 ” , etc. • In C , every string is terminated by ‘0’ . It is null character that is automatically added to the string by the compiler . It is backslash character constant. These are also known as escape sequence character . d) string character constants Vijayalaxmi D Wakode
  • 9. Escape sequence characters • Backslash used in front of these characters tells the compiler to escape from regular behavior and perform the desired function. • List of the other such characters is as shown n new line b backspace t horizontal space o null character r carriage return • The constants can be defined in 2 ways in program. -we can give a direct value that is used as constant. E.g. int a=10. -we can use #define preprocessor directive. E.g. #define PI 3.14 Vijayalaxmi D Wakode
  • 10. iv)Operator • A operator is defined as a symbol that tells the computer to perform certain mathematical or logical manipulation. • These are basically used to manipulate data . • C provides a rich set of built in operators. Vijayalaxmi D Wakode
  • 11. a) Arithmetic Operator • The C language supports various different arithmetic operators as +,-,/,*,%. The % is known as modulus operator used to find remainder of an expression. Integer Arithmetic • An arithmetic operation performed on 2 whole numbers/ integers . It always gives an integer result. In integer division the fractional part is truncated. Floating point Arithmetic • An arithmetic operation performed on 2 real / fractional numbers. It results can be truncated according to the properties requirement. The remainder operator (%) is not applicable for floating point arithmetic operands. Mixed mode Arithmetic • An arithmetic operation performed on 1 of real operands and another integer operand. Its result is always real. Vijayalaxmi D Wakode
  • 12. b)Comparison Operator • These operators are also known as relational operator. These are used to compare 2 quantities. The value of relational expression is either 0/1. If expression is true then 1 and 0 if its false • Syntax : exp1 relational operator exp2. e.g. -90 > 0 false(0), 11> 7+2 true(1) • Relational operator are used in decision making statements in C language. symbols meaning < Less than <= Less than equal to > Greater than >= Greater than equal to == Equal to != Not equal to Vijayalaxmi D Wakode
  • 13. c) Logical Operator • The language supports 3 kinds of logical operator. These are basically used when we want to use more than 1 condition and make certain decision. i)Logical AND (&&) ii)Logical OR(||) iii) Logical NOT(!) A B o/p : A && B 0 0 0 0 1 0 1 0 0 1 1 1 A B o/p : A|| B 0 0 0 0 1 1 1 0 1 1 1 1 A o/p: !A 0 1 1 0 Vijayalaxmi D Wakode
  • 14. v) Assignment Operator • These are used to assign the result of an expression to a variable / it can also be used to assign value to a variable. • In case of assignment operator L.H.S must be a variable but R.H.S can be expression or any constant value. e.g. A = 2, x = A + 3 • C language also supports set of short hand assignment operator . Operator Stmt with simple assign operator Stmt with shorthand property += a=a+1 a+=1 -= a=a-1 a-=1 *= a=a*1 a*=1 /= a=a/1 a/=1 %= a=a%1 a%=1 Vijayalaxmi D Wakode
  • 16. vi)Conditional Operator • Conditional operator operates 3 conditions, hence also known as ternary operator. Syntax : expr1 ? expr2 : expr3; e.g. (5>10)? printf(“5”); : printf(“10”); • Expr1 is evaluated first. Its value is either true or false . If it is true the expr2 is evaluated and this becomes value of complete expr. If expr1 is false, then expr3 is evaluated and this becomes the value of complete expr. Only 1 of the expr’s i.e expr2/ expr3 will be evaluated but not both. • Conditional operator is short form of if…else structure. Vijayalaxmi D Wakode
  • 17. vii)Bitwise Operator • C language also supports various bitwise operator that operates at bit level. These are used to test bits them in left / right. • The o/p of bitwise AND is 1 if all the corresponding bits of all operands is 1. • The o/p of bitwise OR is 1 if at least one corresponding bits of all operands is 1. • The o/p of bitwise XOR is 1 if the corresponding bits of 2 operands are opposite. • Bitwise complement operator is an unary operator. It changes 1 to 0(condition). operator meaning & Bitwise and | Bitwise or ~ Complement ^ Bitwise exclusive or << Shift left >> Shift right Vijayalaxmi D Wakode
  • 18. viii) Special Operator • C language also supports some special operators as comma, sizeof(), pointer operator (*), member selection operator( . ) i) comma operator : It is used to separate variables. e.g. int a,b,c; ii) sizeof operator : The sizeof is a compile time operator that returns the numbers of bytes the operand occupies. The operand may be a variable , constant or datatype qualifier. e.g. int x,y; y=sizeof(x); o/p: y = 2 Vijayalaxmi D Wakode
  • 19. 1.3 Data Types in C • Datatype means type of data which we are going to give to computer for processing. It basically used to calculate the memory requirement. fig. 1.2. Data types in C Vijayalaxmi D Wakode
  • 20. Primary Data Types These are the built in and fundamental data types . Integers are whole numbers i.e. numbers without decimal point. All these data types short int, int, long int have signed & unsigned forms. Unsigned numbers are always positive. Floating point numbers are real numbers. It has 6 digits of precision. These numbers are denoted by keyword float. When accuracy of floating point number is insufficient , we use double keyword, it has 14 digits precision. To extend precision further , we use long double. It is used to specify type of function. When function does not return any value and if there is empty parameter list It is declared using keyword char. It stores single character item. Integer Type Vijayalaxmi D Wakode Floating Point Type Void Type Character Type
  • 21. Storage space requirement Type Size Range short int 8 bits(1 byte) -128 to 127 int or signed int 16 bits(2 bytes) -32768 to 32767 Unsigned int 16 bits(2 bytes) 0 to 65535 Long int 32 bits(4 bytes) -2,147,483,648 to 2,147,483,648 Unsigned long int 32 bits(4 bytes) 0 to 4,294,967,295 Float 32 bits(4 bytes) 2^32 Double 64 bits(8 bytes) 2^64 Long double 80 bits(10 bytes) 2^80 Char 8 bits(1 byte) -128 to 127 Vijayalaxmi D Wakode Table 1.2 Primary data types in C
  • 22. 1.4 Variables in C • A variable is used to store data. It tells compiler variable name and data type of variable. Declaration : datatype identifier; e.g. int x,y,z; Converting lower type to higher type and vice versa, is known as type conversion. Lower type is automatically converted into higher type It is the process of local conversion. Its also known as type casting Syntax : (type name) expression; Type name is standard data type in c Vijayalaxmi D Wakode Type Conversion a) Implicit Conversion b)Explicit Conversion
  • 23. 1.5 Input and Output in C Vijayalaxmi D Wakode fig.1.3 input/output function in C
  • 24. Format specifiers symbol use %d integer %f Float value %c Character value %s String value %u Unsigned integer value %ld Long int Vijayalaxmi D Wakode
  • 25. 1.6 Structure of C Program Documentation Section Link Section Definition Section Global Declaration Section Main() { Declaration Part; Executable Part; } Subprogram Section : Function 1, Function 2, Function 3 Vijayalaxmi D Wakode