SlideShare une entreprise Scribd logo
1  sur  15
C –Imp Points
K.Taruni
The C Character Set
Alphabets

A, B, ….., Y, Z
a, b, ……, y, z

Digits

0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Special symbols

~‘!@#%^&*()_-+=|{}
[]:;"'<>,.?/

 The alphabets, numbers and special symbols when properly combined form constants, variables
and keywords.
 A constant is an entity that doesn‟t change whereas a variable is an entity that may change.
C stores values at memory locations which are
given a particular name.

x

3

x

5

 Since the location whose name is x can hold different values at different times x is
known as a variable. As against this, 3 or 5 do not change, hence are known as constants.
 A character constant is a single alphabet, a single digit or a single special symbol enclosed within
single inverted commas. Both the inverted commas should point to the left.
 For example, ‟A‟ is a valid character constant whereas „A‟ is not.
Following rules must be observed while constructing real
constants expressed in exponential form:





The mantissa part and the exponential part should be separated by a letter e.
The mantissa part may have a positive or negative sign.
Default sign of mantissa part is positive.
The exponent must have at least one digit, which must be a positive or negative integer. Default sign is
positive.

 Range of real constants expressed in exponential form is -3.4e38 to 3.4e38.
 Ex.: +3.2e-5
4.1e8
-0.2e+3

-3.2e-5
Rules for Constructing Variable Names
 A variable name is any combination of 1 to 31 alphabets, digits or underscores.
Some compilers allow variable names whose length could be up to 247
characters. Still, it would be safer to stick to the rule of 31 characters. Do not
create unnecessarily long variable names as it adds to your typing effort.
 The first character in the variable name must be an alphabet or underscore.
 No commas or blanks are allowed within a variable name.
 No special symbol other than an underscore (as in gross_sal) can be used in a
variable name.
C Keywords-cannot be used as variable names
 The keywords are also called „Reserved words‟.
 There are only 32 keywords available in C.
 Note that compiler vendors (like Microsoft,
Borland, etc.) provide their own keywords apart
from the ones mentioned above. These include
extended keywords like near, far, asm, etc.
 Though it has been suggested by the ANSI
committee that every such compiler specific
keyword should be preceded by two
underscores (as in __asm ), not every vendor
follows this rule.
C Program
 C has no specific rules for the position at which a statement is to be written. That‟s why it






is often called a free-form language.
Every C statement must end with a ;. Thus ; acts as a statement terminator.
The statements in a program must appear in the same order in which we wish them to be
executed; unless of course the logic of the problem demands a deliberate „jump‟ or
transfer of control to a statement, which is out of sequence.
Blank spaces may be inserted between two words to improve the readability of the
statement. However, no blank spaces are allowed within a variable, constant or keyword.
All statements are entered in small case letters.
/* Calculation of simple interest */
/* Author gekay Date: 25/05/2004 */

C Program

main( )
{
int p, n ;
float r, si ;
p = 1000 ;
n=3;
r = 8.5 ;
/* formula for simple interest */

 Comments cannot be nested. For example,
/* Cal of SI /* Author sam date 01/01/2002
*/ */

is invalid.

 −A comment can be split over more than
one line, as in,

 /* This is

si = p * n * r / 100 ;

a jazzy

printf ( "%f" , si ) ;

comment */

}
/* Just for fun. Author: Bozo */

main( )
{
int num ;
printf ( "Enter a number" ) ;

 Type declaration instruction −

To declare the
type of variables used in a C program.

scanf ( "%d", &num ) ;

 Arithmetic instruction −
printf ( "Now I am letting you on a secret..." ) ;
printf ( "You have just entered the number %d",
num ) ;
}

To perform
arithmetic operations between constants and
variables.

 Control instruction − To control the sequence
of execution of various statements in a C
program.
Type declarations.
 float a = 1.5, b = a + 3.1 ;
is alright, but
 float b = a + 3.1, a = 1.5 ;
is not because we are trying to
use a before it is even declared.

 The following statements would work
 int a, b, c, d ;
a = b = c = 10 ;
 However, the following statement would
not work
int a = b = c = d = 10 ;
 Once again we are trying to use b (to
assign to a) before defining it.
Arithmetic Operations
Ex.: int ad ;
float kot, deta, alpha, beta, gamma ;
ad = 3200 ;
kot = 0.0056 ;
deta = alpha * beta / gamma + 3.2 * 2 /
5;

Here,
*, /, -, + are the arithmetic operators.
= is the assignment operator.
2, 5 and 3200 are integer constants.
3.2 and 0.0056 are real constants.
ad is an integer variable.
kot, deta, alpha, beta, gamma are real
variables.
Arithmetic Statement – 3 types
Integer mode arithmetic statement This is an arithmetic statement in which
all operands are either integer variables
or integer constants.
Ex.: int i, king, issac, noteit ;
i=i+1;
king = issac * 234 + noteit - 7689 ;

Real mode arithmetic statement - This is
an arithmetic statement in which all
operands are either real constants or real
variables. Ex.: float qbee, antink, si,
prin, anoy, roi ;
qbee = antink + 23.123 / 4.5 * 0.3442 ;
si = prin * anoy * roi / 100.0 ;

 Mixed mode arithmetic statement - This is an arithmetic statement in which
some of the operands are integers and some of the operands are real.
Arithmetic Instructions
Ex.: float si, prin, anoy, roi, avg ;
int a, b, c, num ;
si = prin * anoy * roi / 100.0 ;
avg = ( a + b + c + num ) / 4 ;

 An arithmetic instruction is often used for
storing character constants in character
variables.

char a, b, d ;
a = 'F' ;
b = 'G' ;
d = '+' ;

 C allows only one variable on left-hand side
of =. That is, z = k * l is legal, whereas k * l =
z is illegal.

 In addition to the division operator C also
provides a modular division operator. This
operator returns the remainder on dividing
one integer with another. Thus the expression
10 / 2 yields 5, whereas, 10 % 2 yields 0.
Note that the modulus operator (%) cannot be
applied on a float. Also note that on using %
the sign of the remainder is always same as
the sign of the numerator. Thus –5 % 2 yields
–1, whereas, 5 % -2 yields 1.
Invalid Statements





a = 3 ** 2 ;
b=3^2;
a = c.d.b(xy) usual arithmetic statement
b = c * d * b * ( x * y ) C statement

#include <math.h>
main( )
{
int a ;
a = pow ( 3, 2 ) ;
printf ( “%d”, a ) ;
}

Contenu connexe

Tendances

Cpu-fundamental of C
Cpu-fundamental of CCpu-fundamental of C
Cpu-fundamental of C
Suchit Patel
 

Tendances (19)

CHAPTER 2
CHAPTER 2CHAPTER 2
CHAPTER 2
 
Conversion of in fix pre fix,infix by sarmad baloch
Conversion of in fix pre fix,infix by sarmad balochConversion of in fix pre fix,infix by sarmad baloch
Conversion of in fix pre fix,infix by sarmad baloch
 
Unit 2 c programming_basics
Unit 2 c programming_basicsUnit 2 c programming_basics
Unit 2 c programming_basics
 
Introduction
IntroductionIntroduction
Introduction
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
C Token’s
C Token’sC Token’s
C Token’s
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
Compiler notes--unit-iii
Compiler notes--unit-iiiCompiler notes--unit-iii
Compiler notes--unit-iii
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Cpu-fundamental of C
Cpu-fundamental of CCpu-fundamental of C
Cpu-fundamental of C
 
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
POINTERS IN C MRS.SOWMYA JYOTHI.pdfPOINTERS IN C MRS.SOWMYA JYOTHI.pdf
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
 
CLASS VIII COMPUTERS FLOW CHART AND ALGORITHM
CLASS VIII COMPUTERS FLOW CHART AND ALGORITHMCLASS VIII COMPUTERS FLOW CHART AND ALGORITHM
CLASS VIII COMPUTERS FLOW CHART AND ALGORITHM
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
 
C++ programming
C++ programmingC++ programming
C++ programming
 
C++ revision tour
C++ revision tourC++ revision tour
C++ revision tour
 
Basics of c
Basics of cBasics of c
Basics of c
 
Problem solving with algorithm and data structure
Problem solving with algorithm and data structureProblem solving with algorithm and data structure
Problem solving with algorithm and data structure
 
C programming part4
C programming part4C programming part4
C programming part4
 
USER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdf
USER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdfUSER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdf
USER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdf
 

En vedette

Афиша культурных событий, июль 2013 г.
Афиша культурных событий, июль 2013 г.Афиша культурных событий, июль 2013 г.
Афиша культурных событий, июль 2013 г.
Nazarovo_administration
 
Протокол публичных слушаний "Западный"
Протокол публичных слушаний "Западный"Протокол публичных слушаний "Западный"
Протокол публичных слушаний "Западный"
Nazarovo_administration
 
Sepember 2012 vol 2
Sepember 2012 vol 2Sepember 2012 vol 2
Sepember 2012 vol 2
thewebmaven
 
План работы постоянной комиссии по законносте и защите прав граждан на 2014 год.
План работы постоянной комиссии по законносте и защите прав граждан на 2014 год.План работы постоянной комиссии по законносте и защите прав граждан на 2014 год.
План работы постоянной комиссии по законносте и защите прав граждан на 2014 год.
Nazarovo_administration
 
ส งคม
ส งคมส งคม
ส งคม
280125399
 
положение спартакиада кфк
положение спартакиада кфкположение спартакиада кфк
положение спартакиада кфк
Nazarovo_administration
 
Реестр муниципальных услуг
Реестр муниципальных услугРеестр муниципальных услуг
Реестр муниципальных услуг
Nazarovo_administration
 
Field trips project
Field trips projectField trips project
Field trips project
jaimefoster3
 
План - график создания контейнерных площадок
План - график создания контейнерных площадок План - график создания контейнерных площадок
План - график создания контейнерных площадок
Nazarovo_administration
 
Реестр муниципальных услуг
Реестр муниципальных услугРеестр муниципальных услуг
Реестр муниципальных услуг
Nazarovo_administration
 
Положение конкурса «Конституция Российской Федерации - ориентир для развития...
Положение конкурса «Конституция Российской Федерации -  ориентир для развития...Положение конкурса «Конституция Российской Федерации -  ориентир для развития...
Положение конкурса «Конституция Российской Федерации - ориентир для развития...
Nazarovo_administration
 
Mobile Money Transfer : International Remittance Considerations for Mobile Ne...
Mobile Money Transfer : International Remittance Considerations for Mobile Ne...Mobile Money Transfer : International Remittance Considerations for Mobile Ne...
Mobile Money Transfer : International Remittance Considerations for Mobile Ne...
Andrew Ariaratnam
 
Presentation outline!
Presentation outline!Presentation outline!
Presentation outline!
Sandra Vespa
 

En vedette (20)

Афиша культурных событий, июль 2013 г.
Афиша культурных событий, июль 2013 г.Афиша культурных событий, июль 2013 г.
Афиша культурных событий, июль 2013 г.
 
Протокол публичных слушаний "Западный"
Протокол публичных слушаний "Западный"Протокол публичных слушаний "Западный"
Протокол публичных слушаний "Западный"
 
Eng
EngEng
Eng
 
Sepember 2012 vol 2
Sepember 2012 vol 2Sepember 2012 vol 2
Sepember 2012 vol 2
 
План работы постоянной комиссии по законносте и защите прав граждан на 2014 год.
План работы постоянной комиссии по законносте и защите прав граждан на 2014 год.План работы постоянной комиссии по законносте и защите прав граждан на 2014 год.
План работы постоянной комиссии по законносте и защите прав граждан на 2014 год.
 
BackupAgent presentation on Autotask integration
BackupAgent presentation on Autotask integrationBackupAgent presentation on Autotask integration
BackupAgent presentation on Autotask integration
 
Spss
SpssSpss
Spss
 
ส งคม
ส งคมส งคม
ส งคม
 
положение спартакиада кфк
положение спартакиада кфкположение спартакиада кфк
положение спартакиада кфк
 
Tutorial belajar membuat virtualhost di xampp linux
Tutorial belajar membuat virtualhost di xampp linuxTutorial belajar membuat virtualhost di xampp linux
Tutorial belajar membuat virtualhost di xampp linux
 
Реестр муниципальных услуг
Реестр муниципальных услугРеестр муниципальных услуг
Реестр муниципальных услуг
 
Field trips project
Field trips projectField trips project
Field trips project
 
План - график создания контейнерных площадок
План - график создания контейнерных площадок План - график создания контейнерных площадок
План - график создания контейнерных площадок
 
How to successfully sell cloud backup
How to successfully sell cloud backupHow to successfully sell cloud backup
How to successfully sell cloud backup
 
Реестр муниципальных услуг
Реестр муниципальных услугРеестр муниципальных услуг
Реестр муниципальных услуг
 
Положение конкурса «Конституция Российской Федерации - ориентир для развития...
Положение конкурса «Конституция Российской Федерации -  ориентир для развития...Положение конкурса «Конституция Российской Федерации -  ориентир для развития...
Положение конкурса «Конституция Российской Федерации - ориентир для развития...
 
Mobile Money Transfer : International Remittance Considerations for Mobile Ne...
Mobile Money Transfer : International Remittance Considerations for Mobile Ne...Mobile Money Transfer : International Remittance Considerations for Mobile Ne...
Mobile Money Transfer : International Remittance Considerations for Mobile Ne...
 
Presentation outline!
Presentation outline!Presentation outline!
Presentation outline!
 
Резолюция. Бюджет.
Резолюция. Бюджет.Резолюция. Бюджет.
Резолюция. Бюджет.
 
Manual wordbasico2010
Manual wordbasico2010Manual wordbasico2010
Manual wordbasico2010
 

Similaire à C –imp points

Object Oriented Programming with C++
Object Oriented Programming with C++Object Oriented Programming with C++
Object Oriented Programming with C++
Rokonuzzaman Rony
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
Tony Apreku
 
LESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptxLESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptx
joachimbenedicttulau
 

Similaire à C –imp points (20)

Object Oriented Programming with C++
Object Oriented Programming with C++Object Oriented Programming with C++
Object Oriented Programming with C++
 
5 introduction-to-c
5 introduction-to-c5 introduction-to-c
5 introduction-to-c
 
C Programming
C ProgrammingC Programming
C Programming
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
 
Getting started with C++
Getting started with C++Getting started with C++
Getting started with C++
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++
 
Chapter1.pptx
Chapter1.pptxChapter1.pptx
Chapter1.pptx
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data Types
 
Basics of c
Basics of cBasics of c
Basics of c
 
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
 
Lamborghini Veneno Allegheri #2004@f**ck
Lamborghini Veneno Allegheri #2004@f**ckLamborghini Veneno Allegheri #2004@f**ck
Lamborghini Veneno Allegheri #2004@f**ck
 
C Programming
C ProgrammingC Programming
C Programming
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
#Code2 create c++ for beginners
#Code2 create  c++ for beginners #Code2 create  c++ for beginners
#Code2 create c++ for beginners
 
LESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptxLESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptx
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
 
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
 

Dernier

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
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 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Dernier (20)

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).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
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 

C –imp points

  • 2. The C Character Set Alphabets A, B, ….., Y, Z a, b, ……, y, z Digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Special symbols ~‘!@#%^&*()_-+=|{} []:;"'<>,.?/  The alphabets, numbers and special symbols when properly combined form constants, variables and keywords.  A constant is an entity that doesn‟t change whereas a variable is an entity that may change.
  • 3. C stores values at memory locations which are given a particular name. x 3 x 5  Since the location whose name is x can hold different values at different times x is known as a variable. As against this, 3 or 5 do not change, hence are known as constants.
  • 4.  A character constant is a single alphabet, a single digit or a single special symbol enclosed within single inverted commas. Both the inverted commas should point to the left.  For example, ‟A‟ is a valid character constant whereas „A‟ is not.
  • 5. Following rules must be observed while constructing real constants expressed in exponential form:     The mantissa part and the exponential part should be separated by a letter e. The mantissa part may have a positive or negative sign. Default sign of mantissa part is positive. The exponent must have at least one digit, which must be a positive or negative integer. Default sign is positive.  Range of real constants expressed in exponential form is -3.4e38 to 3.4e38.  Ex.: +3.2e-5 4.1e8 -0.2e+3 -3.2e-5
  • 6. Rules for Constructing Variable Names  A variable name is any combination of 1 to 31 alphabets, digits or underscores. Some compilers allow variable names whose length could be up to 247 characters. Still, it would be safer to stick to the rule of 31 characters. Do not create unnecessarily long variable names as it adds to your typing effort.  The first character in the variable name must be an alphabet or underscore.  No commas or blanks are allowed within a variable name.  No special symbol other than an underscore (as in gross_sal) can be used in a variable name.
  • 7. C Keywords-cannot be used as variable names  The keywords are also called „Reserved words‟.  There are only 32 keywords available in C.  Note that compiler vendors (like Microsoft, Borland, etc.) provide their own keywords apart from the ones mentioned above. These include extended keywords like near, far, asm, etc.  Though it has been suggested by the ANSI committee that every such compiler specific keyword should be preceded by two underscores (as in __asm ), not every vendor follows this rule.
  • 8. C Program  C has no specific rules for the position at which a statement is to be written. That‟s why it     is often called a free-form language. Every C statement must end with a ;. Thus ; acts as a statement terminator. The statements in a program must appear in the same order in which we wish them to be executed; unless of course the logic of the problem demands a deliberate „jump‟ or transfer of control to a statement, which is out of sequence. Blank spaces may be inserted between two words to improve the readability of the statement. However, no blank spaces are allowed within a variable, constant or keyword. All statements are entered in small case letters.
  • 9. /* Calculation of simple interest */ /* Author gekay Date: 25/05/2004 */ C Program main( ) { int p, n ; float r, si ; p = 1000 ; n=3; r = 8.5 ; /* formula for simple interest */  Comments cannot be nested. For example, /* Cal of SI /* Author sam date 01/01/2002 */ */ is invalid.  −A comment can be split over more than one line, as in,  /* This is si = p * n * r / 100 ; a jazzy printf ( "%f" , si ) ; comment */ }
  • 10. /* Just for fun. Author: Bozo */ main( ) { int num ; printf ( "Enter a number" ) ;  Type declaration instruction − To declare the type of variables used in a C program. scanf ( "%d", &num ) ;  Arithmetic instruction − printf ( "Now I am letting you on a secret..." ) ; printf ( "You have just entered the number %d", num ) ; } To perform arithmetic operations between constants and variables.  Control instruction − To control the sequence of execution of various statements in a C program.
  • 11. Type declarations.  float a = 1.5, b = a + 3.1 ; is alright, but  float b = a + 3.1, a = 1.5 ; is not because we are trying to use a before it is even declared.  The following statements would work  int a, b, c, d ; a = b = c = 10 ;  However, the following statement would not work int a = b = c = d = 10 ;  Once again we are trying to use b (to assign to a) before defining it.
  • 12. Arithmetic Operations Ex.: int ad ; float kot, deta, alpha, beta, gamma ; ad = 3200 ; kot = 0.0056 ; deta = alpha * beta / gamma + 3.2 * 2 / 5; Here, *, /, -, + are the arithmetic operators. = is the assignment operator. 2, 5 and 3200 are integer constants. 3.2 and 0.0056 are real constants. ad is an integer variable. kot, deta, alpha, beta, gamma are real variables.
  • 13. Arithmetic Statement – 3 types Integer mode arithmetic statement This is an arithmetic statement in which all operands are either integer variables or integer constants. Ex.: int i, king, issac, noteit ; i=i+1; king = issac * 234 + noteit - 7689 ; Real mode arithmetic statement - This is an arithmetic statement in which all operands are either real constants or real variables. Ex.: float qbee, antink, si, prin, anoy, roi ; qbee = antink + 23.123 / 4.5 * 0.3442 ; si = prin * anoy * roi / 100.0 ;  Mixed mode arithmetic statement - This is an arithmetic statement in which some of the operands are integers and some of the operands are real.
  • 14. Arithmetic Instructions Ex.: float si, prin, anoy, roi, avg ; int a, b, c, num ; si = prin * anoy * roi / 100.0 ; avg = ( a + b + c + num ) / 4 ;  An arithmetic instruction is often used for storing character constants in character variables. char a, b, d ; a = 'F' ; b = 'G' ; d = '+' ;  C allows only one variable on left-hand side of =. That is, z = k * l is legal, whereas k * l = z is illegal.  In addition to the division operator C also provides a modular division operator. This operator returns the remainder on dividing one integer with another. Thus the expression 10 / 2 yields 5, whereas, 10 % 2 yields 0. Note that the modulus operator (%) cannot be applied on a float. Also note that on using % the sign of the remainder is always same as the sign of the numerator. Thus –5 % 2 yields –1, whereas, 5 % -2 yields 1.
  • 15. Invalid Statements     a = 3 ** 2 ; b=3^2; a = c.d.b(xy) usual arithmetic statement b = c * d * b * ( x * y ) C statement #include <math.h> main( ) { int a ; a = pow ( 3, 2 ) ; printf ( “%d”, a ) ; }