SlideShare une entreprise Scribd logo
1  sur  22
1 Introduction to C
2 C Fundamentals
3 Formatted Input/Output
4 Expression
5 Selection Statement
6 Loops
7 Basic Types
8 Arrays
9 Functions
10 Pointers
11 Pointers and Arrays
Introduction to C
1 C is a low-level language
---suitable language for systems programming
2 C is a small language
---relies on a “library” of standard functions
3 C is a permissive language
---it assumes that you know what you’re doing, so it allows you a wider degree
of latitude than many languages. It doesn’t mandate the detailed error-
checking found in other language
Introduction to C
Strengths:
 Efficiency: intended for applications where assembly language
had traditionally been used.
 Portability: hasn’t splintered into incompatible dialects; small
and easily written
 Power: large collection of data types and operators
 Flexibility: not only for system but also for embedded system
commercial data processing
 Standard library
 Integration with UNIX
C Fundamentals
First program
#include <stdio.h>
main()
{
printf(“To C, or not to C: that is the question”);
}
C Fundamentals
Compiling and Linking
Preprocessing: the program is given to a preprocessor,
which obeys commands that begin with #(directives)
add things to the program and make modifications
Compiling: modified programcompilerobject
code
Linking: add library functions to yield a complete
executable program
C Fundamentals
Keywords
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
Tokens in C
 Keywords
• These are reserved words of the C language. For example
int, float, if, else, for, while etc.
 Identifiers
• An Identifier is a sequence of letters and digits, but must
start with a letter. Underscore ( _ ) is treated as a letter.
Identifiers are case sensitive. Identifiers are used to name
variables, functions etc.
• Valid: Root, _getchar, __sin, x1, x2, x3, x_1, If
• Invalid: 324, short, price$, My Name
 Constants
• Constants like 13, ‘a’, 1.3e-5 etc.
String Literals
• A sequence of characters enclosed in double quotes as
“…”. For example “13” is a string literal and not
number 13. ‘a’ and “a” are different.
Operators
• Arithmetic operators like +, -, *, / ,% etc.
• Logical operators like ||, &&, ! etc. and so on.
White Spaces
• Spaces, new lines, tabs, comments ( A sequence of
characters enclosed in /* and */ ) etc. These are used to
separate the adjacent identifiers, kewords and
constants.
Tokens in C
Basic Data Types
 Integral Types
• char Stored as 8 bits. Unsigned 0 to 255.
Signed -128 to 127.
• short int Stored as 16 bits. Unsigned 0 to 65535.
Signed -32768 to 32767.
• int Same as either short or long int.
• long int Stored as 32 bits. Unsigned 0 to 4294967295.
Signed -2147483648 to 2147483647
 Floating Point Numbers
• Floating point numbers are rational numbers. Always signed numbers.
• float Approximate precision of 6 decimal digits .
 Typically stored in 4 bytes with 24 bits of signed mantissa and 8 bits of signed
exponent.
• double Approximate precision of 14 decimal digits.
 Typically stored in 8 bytes with 56 bits of signed mantissa and 8 bits of signed
exponent.
• One should check the file limits.h to what is implemented on a particular
machine.
Basic Data Types
Constants
 Character and string constants
• ‘c’ , a single character in single quotes are stored as char.
Some special character are represented as two characters in single
quotes.
‘n’ = newline, ‘t’= tab, ‘’ = backlash, ‘”’ = double quotes.
Char constants also can be written in terms of their ASCII code.
‘060’ = ‘0’ (Decimal code is 48).
• A sequence of characters enclosed in double quotes is called a string
constant or string literal. For example
“Charu”
“A”
“3/9”
“x = 5”
Declarations
 Declaring a Variable
• Each variable used must be declared.
• A form of a declaration statement is
data-type var1, var2,…;
• Declaration announces the data type of a variable and allocates
appropriate memory location. No initial value (like 0 for integers)
should be assumed.
• It is possible to assign an initial value to a variable in the declaration
itself.
data-type var = expression;
• Examples
int sum = 0;
char newLine = ‘n’;
float epsilon = 1.0e-6;
Precedence and Order of
evaluation
Precedence and Order of
evaluation
Operators
 Relational Operators
• <, <=, > >=, ==, != are the relational operators. The expression
operand1 relational-operator operand2
takes a value of 1(int) if the relationship is true and 0(int) if relationship is false.
• Example
int a = 25, b = 30, c, d;
c = a < b;
d = a > b;
value of c will be 1 and that of d will be 0.
Operators
 Logical Operators
• &&, || and ! are the three logical operators.
• expr1 && expr2 has a value 1 if expr1 and expr2 both are nonzero.
• expr1 || expr2 has a value 1 if expr1 and expr2 both are nonzero.
• !expr1 has a value 1 if expr1 is zero else 0.
• Example
• if ( marks >= 40 && attendance >= 75 ) grade = ‘P’
• If ( marks < 40 || attendance < 75 ) grade = ‘N’
Operators
 Assignment operators
• The general form of an assignment operator is
• v op= exp
• Where v is a variable and op is a binary arithmetic operator. This statement is
equivalent to
• v = v op (exp)
• a = a + b can be written as a += b
• a = a * b can be written as a *= b
• a = a / b can be written as a /= b
• a = a - b can be written as a -= b
Operators
 Increment and Decrement Operators
• The operators ++ and –- are called increment and decrement operators.
• a++ and ++a are equivalent to a += 1.
• a-- and --a are equivalent to a -= 1.
• ++a op b is equivalent to a ++; a op b;
• a++ op b is equivalent to a op b; a++;
• Example
Let b = 10 then
(++b)+b+b = 33
b+(++b)+b = 33
b+b+(++b) = 31
b+b*(++b) = 132
Floating Point Arithmetic
 Representation
• All floating point numbers are stored as
• such that d1 is nonzero. B is the base. p is the precision or number of significant
digits. e is the exponent. All these put together have finite number of bits
(usually 32 or 64 bits ) of storage.
• Example
• Assume B = 10 and p = 3.
• 23.7 = +0.237E2
• 23.74 = +0.237E2
• 37000 = +0.370E5
• 37028 = +0.370E5
• -0.000124 = -0.124E-4
Floating Point Arithmetic
 Representation
• Sk = { x | Bk-1 <= x < Bk }. Number of elements in each Sk is same. In the
previous example it is 900.
• Gap between seuccessive numbers of Sk is Bk-p.
• B1-p is called machine epsilon. It is the gap between 1 and next representable
number.
• Underflow and Overflow occur when number cannot be represented because it
is too small or too big.
• Two floating points are added by aligning decimal points.
• Floating point arithmetic is not associative and distributive.
we provide online and classroom training for
“C” Language
For More Details
www.asit.amcsquare.com
Wise Machines India Pvt Ltd
#360, Sri Sai Padma Arcade,
Varthur Main Road,
Ramagondanahalli,
Whitefiled ,Bangalore – 560066.
We also having Branches in Hyderabad & Chennai

Contenu connexe

Tendances

Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
Tony Apreku
 

Tendances (20)

Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
 
Keywords, identifiers ,datatypes in C++
Keywords, identifiers ,datatypes in C++Keywords, identifiers ,datatypes in C++
Keywords, identifiers ,datatypes in C++
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Data types
Data typesData types
Data types
 
Lecture02(constants, variable & data types)
Lecture02(constants, variable & data types)Lecture02(constants, variable & data types)
Lecture02(constants, variable & data types)
 
Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
 
2 expressions (ppt-2) in C++
2 expressions (ppt-2) in C++2 expressions (ppt-2) in C++
2 expressions (ppt-2) in C++
 
Literals, primitive datatypes, variables, expressions, identifiers
Literals, primitive datatypes, variables, expressions, identifiersLiterals, primitive datatypes, variables, expressions, identifiers
Literals, primitive datatypes, variables, expressions, identifiers
 
C language
C languageC language
C language
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Basics of c++
Basics of c++Basics of c++
Basics of c++
 
Unit 2. Elements of C
Unit 2. Elements of CUnit 2. Elements of C
Unit 2. Elements of C
 
Strings in c language
Strings in  c languageStrings in  c language
Strings in c language
 
CSharp Language Overview Part 1
CSharp Language Overview Part 1CSharp Language Overview Part 1
CSharp Language Overview Part 1
 
Constant and variacles in c
Constant   and variacles in cConstant   and variacles in c
Constant and variacles in c
 
Unit4 Slides
Unit4 SlidesUnit4 Slides
Unit4 Slides
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
 
Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2
 

Similaire à Learn C LANGUAGE at ASIT

Introduction of c_language
Introduction of c_languageIntroduction of c_language
Introduction of c_language
SINGH PROJECTS
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
TAlha MAlik
 

Similaire à Learn C LANGUAGE at ASIT (20)

Chapter 2: Elementary Programming
Chapter 2: Elementary ProgrammingChapter 2: Elementary Programming
Chapter 2: Elementary Programming
 
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
 
Introduction of c_language
Introduction of c_languageIntroduction of c_language
Introduction of c_language
 
C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginner
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
fundamentals of c
fundamentals of cfundamentals of c
fundamentals of c
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Programming in c
Programming in cProgramming in c
Programming in c
 
lecture2.ppt
lecture2.pptlecture2.ppt
lecture2.ppt
 
Chapter-2 is for tokens in C programming
Chapter-2 is for tokens in C programmingChapter-2 is for tokens in C programming
Chapter-2 is for tokens in C programming
 
Lamborghini Veneno Allegheri #2004@f**ck
Lamborghini Veneno Allegheri #2004@f**ckLamborghini Veneno Allegheri #2004@f**ck
Lamborghini Veneno Allegheri #2004@f**ck
 
C tokens.pptx
C tokens.pptxC tokens.pptx
C tokens.pptx
 
All C ppt.ppt
All C ppt.pptAll C ppt.ppt
All C ppt.ppt
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
 
Introduction to C
Introduction to CIntroduction to C
Introduction to C
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
 
C language
C languageC language
C language
 
Token and operators
Token and operatorsToken and operators
Token and operators
 
Python
PythonPython
Python
 
C PADHLO FRANDS.pdf
C PADHLO FRANDS.pdfC PADHLO FRANDS.pdf
C PADHLO FRANDS.pdf
 

Plus de ASIT

Asit Never Cheats Unemployes
Asit Never Cheats UnemployesAsit Never Cheats Unemployes
Asit Never Cheats Unemployes
ASIT
 
Asit amc never cheats students
Asit amc never cheats studentsAsit amc never cheats students
Asit amc never cheats students
ASIT
 

Plus de ASIT (20)

Asit education student review
Asit education student reviewAsit education student review
Asit education student review
 
ASIT EDUCATION STUDENT REVIEWS
ASIT EDUCATION STUDENT REVIEWSASIT EDUCATION STUDENT REVIEWS
ASIT EDUCATION STUDENT REVIEWS
 
Asit Education
Asit EducationAsit Education
Asit Education
 
Asit Education Student Reviews
Asit Education Student ReviewsAsit Education Student Reviews
Asit Education Student Reviews
 
Asit education Student review
Asit education Student reviewAsit education Student review
Asit education Student review
 
ASIT EDUCATION REVIEW
ASIT EDUCATION REVIEWASIT EDUCATION REVIEW
ASIT EDUCATION REVIEW
 
Asit Never Cheats Unemployes
Asit Never Cheats UnemployesAsit Never Cheats Unemployes
Asit Never Cheats Unemployes
 
Latest News on Amc Square Asit
Latest News on Amc Square AsitLatest News on Amc Square Asit
Latest News on Amc Square Asit
 
Asit amc never cheats students
Asit amc never cheats studentsAsit amc never cheats students
Asit amc never cheats students
 
News on AMC Square ASIT
News on AMC Square ASITNews on AMC Square ASIT
News on AMC Square ASIT
 
News on Asit Amc
News on Asit AmcNews on Asit Amc
News on Asit Amc
 
Time Management
Time ManagementTime Management
Time Management
 
learn Ruby at ASIT
learn Ruby at ASITlearn Ruby at ASIT
learn Ruby at ASIT
 
introduction to Mongodb
introduction to Mongodbintroduction to Mongodb
introduction to Mongodb
 
introduction to hadoop
introduction to hadoopintroduction to hadoop
introduction to hadoop
 
ASIT REVIEWS
ASIT REVIEWSASIT REVIEWS
ASIT REVIEWS
 
ASIT REVIEWS
ASIT REVIEWSASIT REVIEWS
ASIT REVIEWS
 
Learn REST API at ASIT
Learn REST API at ASITLearn REST API at ASIT
Learn REST API at ASIT
 
Learn Advanced JAVA at ASIT
Learn Advanced JAVA at ASITLearn Advanced JAVA at ASIT
Learn Advanced JAVA at ASIT
 
Learn WCF at ASIT
Learn  WCF at ASITLearn  WCF at ASIT
Learn WCF at ASIT
 

Dernier

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 

Dernier (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 

Learn C LANGUAGE at ASIT

  • 1.
  • 2. 1 Introduction to C 2 C Fundamentals 3 Formatted Input/Output 4 Expression 5 Selection Statement 6 Loops 7 Basic Types 8 Arrays 9 Functions 10 Pointers 11 Pointers and Arrays
  • 3. Introduction to C 1 C is a low-level language ---suitable language for systems programming 2 C is a small language ---relies on a “library” of standard functions 3 C is a permissive language ---it assumes that you know what you’re doing, so it allows you a wider degree of latitude than many languages. It doesn’t mandate the detailed error- checking found in other language
  • 4. Introduction to C Strengths:  Efficiency: intended for applications where assembly language had traditionally been used.  Portability: hasn’t splintered into incompatible dialects; small and easily written  Power: large collection of data types and operators  Flexibility: not only for system but also for embedded system commercial data processing  Standard library  Integration with UNIX
  • 5. C Fundamentals First program #include <stdio.h> main() { printf(“To C, or not to C: that is the question”); }
  • 6. C Fundamentals Compiling and Linking Preprocessing: the program is given to a preprocessor, which obeys commands that begin with #(directives) add things to the program and make modifications Compiling: modified programcompilerobject code Linking: add library functions to yield a complete executable program
  • 7. C Fundamentals Keywords 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
  • 8. Tokens in C  Keywords • These are reserved words of the C language. For example int, float, if, else, for, while etc.  Identifiers • An Identifier is a sequence of letters and digits, but must start with a letter. Underscore ( _ ) is treated as a letter. Identifiers are case sensitive. Identifiers are used to name variables, functions etc. • Valid: Root, _getchar, __sin, x1, x2, x3, x_1, If • Invalid: 324, short, price$, My Name  Constants • Constants like 13, ‘a’, 1.3e-5 etc.
  • 9. String Literals • A sequence of characters enclosed in double quotes as “…”. For example “13” is a string literal and not number 13. ‘a’ and “a” are different. Operators • Arithmetic operators like +, -, *, / ,% etc. • Logical operators like ||, &&, ! etc. and so on. White Spaces • Spaces, new lines, tabs, comments ( A sequence of characters enclosed in /* and */ ) etc. These are used to separate the adjacent identifiers, kewords and constants. Tokens in C
  • 10. Basic Data Types  Integral Types • char Stored as 8 bits. Unsigned 0 to 255. Signed -128 to 127. • short int Stored as 16 bits. Unsigned 0 to 65535. Signed -32768 to 32767. • int Same as either short or long int. • long int Stored as 32 bits. Unsigned 0 to 4294967295. Signed -2147483648 to 2147483647
  • 11.  Floating Point Numbers • Floating point numbers are rational numbers. Always signed numbers. • float Approximate precision of 6 decimal digits .  Typically stored in 4 bytes with 24 bits of signed mantissa and 8 bits of signed exponent. • double Approximate precision of 14 decimal digits.  Typically stored in 8 bytes with 56 bits of signed mantissa and 8 bits of signed exponent. • One should check the file limits.h to what is implemented on a particular machine. Basic Data Types
  • 12. Constants  Character and string constants • ‘c’ , a single character in single quotes are stored as char. Some special character are represented as two characters in single quotes. ‘n’ = newline, ‘t’= tab, ‘’ = backlash, ‘”’ = double quotes. Char constants also can be written in terms of their ASCII code. ‘060’ = ‘0’ (Decimal code is 48). • A sequence of characters enclosed in double quotes is called a string constant or string literal. For example “Charu” “A” “3/9” “x = 5”
  • 13. Declarations  Declaring a Variable • Each variable used must be declared. • A form of a declaration statement is data-type var1, var2,…; • Declaration announces the data type of a variable and allocates appropriate memory location. No initial value (like 0 for integers) should be assumed. • It is possible to assign an initial value to a variable in the declaration itself. data-type var = expression; • Examples int sum = 0; char newLine = ‘n’; float epsilon = 1.0e-6;
  • 14. Precedence and Order of evaluation
  • 15. Precedence and Order of evaluation
  • 16. Operators  Relational Operators • <, <=, > >=, ==, != are the relational operators. The expression operand1 relational-operator operand2 takes a value of 1(int) if the relationship is true and 0(int) if relationship is false. • Example int a = 25, b = 30, c, d; c = a < b; d = a > b; value of c will be 1 and that of d will be 0.
  • 17. Operators  Logical Operators • &&, || and ! are the three logical operators. • expr1 && expr2 has a value 1 if expr1 and expr2 both are nonzero. • expr1 || expr2 has a value 1 if expr1 and expr2 both are nonzero. • !expr1 has a value 1 if expr1 is zero else 0. • Example • if ( marks >= 40 && attendance >= 75 ) grade = ‘P’ • If ( marks < 40 || attendance < 75 ) grade = ‘N’
  • 18. Operators  Assignment operators • The general form of an assignment operator is • v op= exp • Where v is a variable and op is a binary arithmetic operator. This statement is equivalent to • v = v op (exp) • a = a + b can be written as a += b • a = a * b can be written as a *= b • a = a / b can be written as a /= b • a = a - b can be written as a -= b
  • 19. Operators  Increment and Decrement Operators • The operators ++ and –- are called increment and decrement operators. • a++ and ++a are equivalent to a += 1. • a-- and --a are equivalent to a -= 1. • ++a op b is equivalent to a ++; a op b; • a++ op b is equivalent to a op b; a++; • Example Let b = 10 then (++b)+b+b = 33 b+(++b)+b = 33 b+b+(++b) = 31 b+b*(++b) = 132
  • 20. Floating Point Arithmetic  Representation • All floating point numbers are stored as • such that d1 is nonzero. B is the base. p is the precision or number of significant digits. e is the exponent. All these put together have finite number of bits (usually 32 or 64 bits ) of storage. • Example • Assume B = 10 and p = 3. • 23.7 = +0.237E2 • 23.74 = +0.237E2 • 37000 = +0.370E5 • 37028 = +0.370E5 • -0.000124 = -0.124E-4
  • 21. Floating Point Arithmetic  Representation • Sk = { x | Bk-1 <= x < Bk }. Number of elements in each Sk is same. In the previous example it is 900. • Gap between seuccessive numbers of Sk is Bk-p. • B1-p is called machine epsilon. It is the gap between 1 and next representable number. • Underflow and Overflow occur when number cannot be represented because it is too small or too big. • Two floating points are added by aligning decimal points. • Floating point arithmetic is not associative and distributive.
  • 22. we provide online and classroom training for “C” Language For More Details www.asit.amcsquare.com Wise Machines India Pvt Ltd #360, Sri Sai Padma Arcade, Varthur Main Road, Ramagondanahalli, Whitefiled ,Bangalore – 560066. We also having Branches in Hyderabad & Chennai