SlideShare a Scribd company logo
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)

PPTX
C Tokens
Ripon Hossain
 
PPTX
C language unit-1
Malikireddy Bramhananda Reddy
 
PPSX
Programming in c
vineet4523
 
PPTX
Fundamentals of c programming
Chitrank Dixit
 
PPT
Programming in c
indra Kishor
 
PDF
Unit ii chapter 1 operator and expressions in c
Sowmya Jyothi
 
PPTX
C functions
University of Potsdam
 
PPTX
Constants, Variables, and Data Types
Rokonuzzaman Rony
 
PDF
Function in C
Dr. Abhineet Anand
 
PPTX
Control statements in c
Sathish Narayanan
 
PPT
Variables in C Programming
programming9
 
PPT
C program
AJAL A J
 
PPTX
C++ presentation
SudhanshuVijay3
 
PPTX
Data types in C language
kashyap399
 
PPTX
Functions in C
Kamal Acharya
 
PPTX
C keywords and identifiers
Akhileshwar Reddy Ankireddy
 
PPT
Strings Functions in C Programming
DevoAjit Gupta
 
PPT
Storage classes
Leela Koneru
 
C Tokens
Ripon Hossain
 
Programming in c
vineet4523
 
Fundamentals of c programming
Chitrank Dixit
 
Programming in c
indra Kishor
 
Unit ii chapter 1 operator and expressions in c
Sowmya Jyothi
 
Constants, Variables, and Data Types
Rokonuzzaman Rony
 
Function in C
Dr. Abhineet Anand
 
Control statements in c
Sathish Narayanan
 
Variables in C Programming
programming9
 
C program
AJAL A J
 
C++ presentation
SudhanshuVijay3
 
Data types in C language
kashyap399
 
Functions in C
Kamal Acharya
 
C keywords and identifiers
Akhileshwar Reddy Ankireddy
 
Strings Functions in C Programming
DevoAjit Gupta
 
Storage classes
Leela Koneru
 

Viewers also liked (20)

PPSX
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
PPT
Basics of C programming
avikdhupar
 
PPTX
C Programming Language Tutorial for beginners - JavaTpoint
JavaTpoint.Com
 
PDF
Introduction of c_language
SINGH PROJECTS
 
PPTX
programming c language.
Abdul Rehman
 
PPT
Oops And C++ Fundamentals
Subhasis Nayak
 
PPTX
Uses of computers
Nazmul Hetfield Batchu
 
PDF
Data Structure in C Programming Language
Arkadeep Dey
 
PDF
Lecture 2 history_of_c
eShikshak
 
PPTX
C++ history session 00 history
Arun Prakash
 
PPTX
C vs c++
Gaurav Badhan
 
PPTX
Victorian Crisis in Tennyson’s "Lotos Eaters"
Nazmul Hetfield Batchu
 
PPTX
Overview of c language
shalini392
 
PPT
Computer History
Crystal Cunningham
 
PPTX
Array in c language
home
 
PPTX
C language ppt
Ğäùråv Júñêjå
 
PPT
History Of Computer
guest420b9d
 
PPTX
Generations of computer
Jatin Jindal
 
PDF
Learning c - An extensive guide to learn the C Language
Abhishek Dwivedi
 
PPTX
GENERATION OF COMPUTERS.
Sowjanya Sampathkumar
 
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
Basics of C programming
avikdhupar
 
C Programming Language Tutorial for beginners - JavaTpoint
JavaTpoint.Com
 
Introduction of c_language
SINGH PROJECTS
 
programming c language.
Abdul Rehman
 
Oops And C++ Fundamentals
Subhasis Nayak
 
Uses of computers
Nazmul Hetfield Batchu
 
Data Structure in C Programming Language
Arkadeep Dey
 
Lecture 2 history_of_c
eShikshak
 
C++ history session 00 history
Arun Prakash
 
C vs c++
Gaurav Badhan
 
Victorian Crisis in Tennyson’s "Lotos Eaters"
Nazmul Hetfield Batchu
 
Overview of c language
shalini392
 
Computer History
Crystal Cunningham
 
Array in c language
home
 
C language ppt
Ğäùråv Júñêjå
 
History Of Computer
guest420b9d
 
Generations of computer
Jatin Jindal
 
Learning c - An extensive guide to learn the C Language
Abhishek Dwivedi
 
GENERATION OF COMPUTERS.
Sowjanya Sampathkumar
 
Ad

Similar to fundamentals of c (20)

PPTX
Introduction to fundamentaals of computing.pptx
shitaldumbre10
 
PPT
M.Florence Dayana / Basics of C Language
Dr.Florence Dayana
 
PPTX
BCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptx
RutviBaraiya
 
PPTX
Chapter 2: Elementary Programming
Eric Chou
 
DOC
C language
SMS2007
 
PPTX
Msc prev completed
mshoaib15
 
PPTX
Msc prev updated
mshoaib15
 
PPTX
Module 1:Introduction
nikshaikh786
 
ODP
Basic C Programming language
Abhishek Soni
 
ODP
Basics Of C Programming For Beginners In Easiest Way
akshay rajpure
 
PPT
All C ppt.ppt
JeelBhanderi4
 
PPT
C presentation book
krunal1210
 
PPTX
C# lecture 2: Literals , Variables and Data Types in C#
Dr.Neeraj Kumar Pandey
 
PDF
C programming.pdf
JitendraYadav351971
 
PPT
Basics of C.ppt
gprasannakumarPrasan
 
PPT
Basics of C.ppt
SangramNayak23
 
PPTX
Data Type in C Programming
Qazi Shahzad Ali
 
PDF
C Programming Language Introduction and C Tokens.pdf
poongothai11
 
PPTX
#Code2 create c++ for beginners
GDGKuwaitGoogleDevel
 
PPT
Funa-C.ppt
ssuser5ad1571
 
Introduction to fundamentaals of computing.pptx
shitaldumbre10
 
M.Florence Dayana / Basics of C Language
Dr.Florence Dayana
 
BCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptx
RutviBaraiya
 
Chapter 2: Elementary Programming
Eric Chou
 
C language
SMS2007
 
Msc prev completed
mshoaib15
 
Msc prev updated
mshoaib15
 
Module 1:Introduction
nikshaikh786
 
Basic C Programming language
Abhishek Soni
 
Basics Of C Programming For Beginners In Easiest Way
akshay rajpure
 
All C ppt.ppt
JeelBhanderi4
 
C presentation book
krunal1210
 
C# lecture 2: Literals , Variables and Data Types in C#
Dr.Neeraj Kumar Pandey
 
C programming.pdf
JitendraYadav351971
 
Basics of C.ppt
gprasannakumarPrasan
 
Basics of C.ppt
SangramNayak23
 
Data Type in C Programming
Qazi Shahzad Ali
 
C Programming Language Introduction and C Tokens.pdf
poongothai11
 
#Code2 create c++ for beginners
GDGKuwaitGoogleDevel
 
Funa-C.ppt
ssuser5ad1571
 
Ad

Recently uploaded (20)

PDF
勉強会資料_An Image is Worth More Than 16x16 Patches
NABLAS株式会社
 
PDF
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
PPTX
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
PDF
The Complete Guide to the Role of the Fourth Engineer On Ships
Mahmoud Moghtaderi
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
Introduction to Fluid and Thermal Engineering
Avesahemad Husainy
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
PDF
Zero Carbon Building Performance standard
BassemOsman1
 
PDF
IEEE EMBC 2025 「Improving electrolaryngeal speech enhancement via a represent...
NU_I_TODALAB
 
PPTX
Water resources Engineering GIS KRT.pptx
Krunal Thanki
 
PDF
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PDF
CAD-CAM U-1 Combined Notes_57761226_2025_04_22_14_40.pdf
shailendrapratap2002
 
PPTX
filteration _ pre.pptx 11111110001.pptx
awasthivaibhav825
 
PDF
STUDY OF NOVEL CHANNEL MATERIALS USING III-V COMPOUNDS WITH VARIOUS GATE DIEL...
ijoejnl
 
PDF
4 Tier Teamcenter Installation part1.pdf
VnyKumar1
 
PPTX
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
PDF
SG1-ALM-MS-EL-30-0008 (00) MS - Isolators and disconnecting switches.pdf
djiceramil
 
PPTX
Inventory management chapter in automation and robotics.
atisht0104
 
勉強会資料_An Image is Worth More Than 16x16 Patches
NABLAS株式会社
 
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
The Complete Guide to the Role of the Fourth Engineer On Ships
Mahmoud Moghtaderi
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Introduction to Fluid and Thermal Engineering
Avesahemad Husainy
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
Zero Carbon Building Performance standard
BassemOsman1
 
IEEE EMBC 2025 「Improving electrolaryngeal speech enhancement via a represent...
NU_I_TODALAB
 
Water resources Engineering GIS KRT.pptx
Krunal Thanki
 
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
CAD-CAM U-1 Combined Notes_57761226_2025_04_22_14_40.pdf
shailendrapratap2002
 
filteration _ pre.pptx 11111110001.pptx
awasthivaibhav825
 
STUDY OF NOVEL CHANNEL MATERIALS USING III-V COMPOUNDS WITH VARIOUS GATE DIEL...
ijoejnl
 
4 Tier Teamcenter Installation part1.pdf
VnyKumar1
 
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
SG1-ALM-MS-EL-30-0008 (00) MS - Isolators and disconnecting switches.pdf
djiceramil
 
Inventory management chapter in automation and robotics.
atisht0104
 

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