SlideShare a Scribd company logo
1 of 12
Basics of C language.Basics of C language.
Tokens in C
Basic data types
Constants and variables.
Tokens in CTokens 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.
http://www.fita.in/c-c-training-in-chennai/
Tokens in CTokens in C
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.
http://www.fita.in/c-c-training-in-chennai/
Basic Data TypesBasic Data TypesIntegral Types
◦ Integers are stored in various sizes. They can be signed or
unsigned.
◦ Example
Suppose an integer is represented by a byte (8 bits).
Leftmost bit is sign bit. If the sign bit is 0, the number is
treated as positive.
Bit pattern 01001011 = 75 (decimal).
The largest positive number is 01111111 = 27
– 1 = 127.
Negative numbers are stored as two’s complement or as
one’s complement.
-75 = 10110100 (one’s complement).
-75 = 10110101 (two’s complement).
http://www.fita.in/c-c-training-in-chennai/
Basic Data TypesBasic 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
http://www.fita.in/c-c-training-in-chennai/
Basic Data TypesBasic Data Types
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.
http://www.fita.in/c-c-training-in-chennai/
ConstantsConstantsNumerical Constants
◦ Constants like 12, 253 are stored as int type. No
decimal point.
◦ 12L or 12l are stored as long int.
◦ 12U or 12u are stored as unsigned int.
◦ 12UL or 12ul are stored as unsigned long int.
◦ Numbers with a decimal point (12.34) are stored as
double.
◦ Numbers with exponent (12e-3 = 12 x 10-3
) are stored as
double.
◦ 12.34f or 1.234e1f are stored as float.
◦ These are not valid constants:
25,000 7.1e 4 $200 2.3e-3.4 etc.
http://www.fita.in/c-c-training-in-chennai/
ConstantsConstants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”
http://www.fita.in/c-c-training-in-chennai/
VariablesVariables
Naming a Variable
◦ Must be a valid identifier.
◦ Must not be a keyword
◦ Names are case sensitive.
◦ Variables are identified by only first 32
characters.
◦ Library commonly uses names beginning with _.
◦ Naming Styles: Uppercase style and Underscore
style
◦ lowerLimit lower_limit
◦ incomeTax income_tax
http://www.fita.in/c-c-training-in-chennai/
DeclarationsDeclarations
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;
http://www.fita.in/c-c-training-in-chennai/
Global and Local VariablesGlobal and Local Variables
Global
Variables
◦ These variables are
declared outside all
functions.
◦ Life time of a global
variable is the entire
execution period of the
program.
◦ Can be accessed by any
function defined below
the declaration, in a
file.
/* Compute Area and Perimeter of
a circle */
#include <stdio.h>
float pi = 3.14159; /* Global */
main() {
float rad; /* Local */
printf( “Enter the radius “ );
scanf(“%f” , &rad);
if ( rad > 0.0 ) {
float area = pi * rad * rad;
float peri = 2 * pi * rad;
printf( “Area = %fn” ,
area );
printf( “Peri = %fn” ,
peri );
}
else
printf( “Negative radiusn”);
printf( “Area = %fn” , area );
}
/* Compute Area and Perimeter of
a circle */
#include <stdio.h>
float pi = 3.14159; /* Global */
main() {
float rad; /* Local */
printf( “Enter the radius “ );
scanf(“%f” , &rad);
if ( rad > 0.0 ) {
float area = pi * rad * rad;
float peri = 2 * pi * rad;
printf( “Area = %fn” ,
area );
printf( “Peri = %fn” ,
peri );
}
else
printf( “Negative radiusn”);
printf( “Area = %fn” , area );
}
http://www.fita.in/c-c-training-in-chennai/
Global and Local VariablesGlobal and Local Variables
Local Variables
◦ These variables are
declared inside some
functions.
◦ Life time of a local
variable is the entire
execution period of the
function in which it is
defined.
◦ Cannot be accessed by
any other function.
◦ In general variables
declared inside a block
are accessible only in
that block.
/* Compute Area and Perimeter of
a circle */
#include <stdio.h>
float pi = 3.14159; /* Global */
main() {
float rad; /* Local */
printf( “Enter the radius “ );
scanf(“%f” , &rad);
if ( rad > 0.0 ) {
float area = pi * rad * rad;
float peri = 2 * pi * rad;
printf( “Area = %fn” ,
area );
printf( “Peri = %fn” ,
peri );
}
else
printf( “Negative radiusn”);
printf( “Area = %fn” , area );
}
/* Compute Area and Perimeter of
a circle */
#include <stdio.h>
float pi = 3.14159; /* Global */
main() {
float rad; /* Local */
printf( “Enter the radius “ );
scanf(“%f” , &rad);
if ( rad > 0.0 ) {
float area = pi * rad * rad;
float peri = 2 * pi * rad;
printf( “Area = %fn” ,
area );
printf( “Peri = %fn” ,
peri );
}
else
printf( “Negative radiusn”);
printf( “Area = %fn” , area );
}
http://www.fita.in/c-c-training-in-chennai/

More Related Content

What's hot

OpenGurukul : Language : C Programming
OpenGurukul : Language : C ProgrammingOpenGurukul : Language : C Programming
OpenGurukul : Language : C ProgrammingOpen Gurukul
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)sachindane
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdfSowmyaJyothi3
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSowmyaJyothi3
 
Introduction to c language
Introduction to c languageIntroduction to c language
Introduction to c languageRavindraSalunke3
 
Moving Average Filter in C
Moving Average Filter in CMoving Average Filter in C
Moving Average Filter in CColin
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++K Durga Prasad
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01Wingston
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programmingprogramming9
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic conceptsAbhinav Vatsa
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial javaTpoint s
 
C programming_MSBTE_Diploma_Pranoti Doke
C programming_MSBTE_Diploma_Pranoti DokeC programming_MSBTE_Diploma_Pranoti Doke
C programming_MSBTE_Diploma_Pranoti DokePranoti Doke
 

What's hot (20)

OpenGurukul : Language : C Programming
OpenGurukul : Language : C ProgrammingOpenGurukul : Language : C Programming
OpenGurukul : Language : C Programming
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
What is c
What is cWhat is c
What is c
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
 
C language basics
C language basicsC language basics
C language basics
 
C language
C languageC language
C language
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
 
Declaration of variables
Declaration of variablesDeclaration of variables
Declaration of variables
 
Introduction to c language
Introduction to c languageIntroduction to c language
Introduction to c language
 
C programming language
C programming languageC programming language
C programming language
 
C fundamentals
C fundamentalsC fundamentals
C fundamentals
 
C Programming
C ProgrammingC Programming
C Programming
 
Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
 
Moving Average Filter in C
Moving Average Filter in CMoving Average Filter in C
Moving Average Filter in C
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
C programming_MSBTE_Diploma_Pranoti Doke
C programming_MSBTE_Diploma_Pranoti DokeC programming_MSBTE_Diploma_Pranoti Doke
C programming_MSBTE_Diploma_Pranoti Doke
 

Viewers also liked

Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programmingavikdhupar
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGAbhishek Dwivedi
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data typesManisha Keim
 
Operation of mosfet with different vgs and vds
Operation of mosfet with different vgs and vdsOperation of mosfet with different vgs and vds
Operation of mosfet with different vgs and vdsHaris Hassan
 
Ese570 mos theory_p206
Ese570 mos theory_p206Ese570 mos theory_p206
Ese570 mos theory_p206bheemsain
 
Programming languages
Programming languagesProgramming languages
Programming languagesvito_carleone
 
Programming in ansi C by Balaguruswami
Programming in ansi C by BalaguruswamiProgramming in ansi C by Balaguruswami
Programming in ansi C by BalaguruswamiPriya Chauhan
 
Types of MOSFET Applications and Working Operation
Types of MOSFET Applications and Working OperationTypes of MOSFET Applications and Working Operation
Types of MOSFET Applications and Working OperationEdgefxkits & Solutions
 
Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)mujeeb memon
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingManoj Tyagi
 
Vb decision making statements
Vb decision making statementsVb decision making statements
Vb decision making statementspragya ratan
 

Viewers also liked (20)

C ppt
C pptC ppt
C ppt
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
C pointers
C pointersC pointers
C pointers
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
 
14827 mosfet
14827 mosfet14827 mosfet
14827 mosfet
 
Operation of mosfet with different vgs and vds
Operation of mosfet with different vgs and vdsOperation of mosfet with different vgs and vds
Operation of mosfet with different vgs and vds
 
Chapter 3 cmos(class2)
Chapter 3 cmos(class2)Chapter 3 cmos(class2)
Chapter 3 cmos(class2)
 
Ese570 mos theory_p206
Ese570 mos theory_p206Ese570 mos theory_p206
Ese570 mos theory_p206
 
1 mosfet 1 basics
1 mosfet 1 basics1 mosfet 1 basics
1 mosfet 1 basics
 
15 mosfet threshold voltage
15 mosfet threshold voltage15 mosfet threshold voltage
15 mosfet threshold voltage
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Programming in ansi C by Balaguruswami
Programming in ansi C by BalaguruswamiProgramming in ansi C by Balaguruswami
Programming in ansi C by Balaguruswami
 
Concept of c
Concept of cConcept of c
Concept of c
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 
Chapter 4 computer language
Chapter 4 computer languageChapter 4 computer language
Chapter 4 computer language
 
Types of MOSFET Applications and Working Operation
Types of MOSFET Applications and Working OperationTypes of MOSFET Applications and Working Operation
Types of MOSFET Applications and Working Operation
 
Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Vb decision making statements
Vb decision making statementsVb decision making statements
Vb decision making statements
 

Similar to C language basics

Chapter 2: Elementary Programming
Chapter 2: Elementary ProgrammingChapter 2: Elementary Programming
Chapter 2: Elementary ProgrammingEric Chou
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointersSamiksha Pun
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptxvijayapraba1
 
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 programmingz9819898203
 
Learn C LANGUAGE at ASIT
Learn C LANGUAGE at ASITLearn C LANGUAGE at ASIT
Learn C LANGUAGE at ASITASIT
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variableseShikshak
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2rohassanie
 
01 Java Language And OOP PART I
01 Java Language And OOP PART I01 Java Language And OOP PART I
01 Java Language And OOP PART IHari Christian
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++NIDA HUSSAIN
 
Lecture 2 keyword of C Programming Language
Lecture 2 keyword of C Programming LanguageLecture 2 keyword of C Programming Language
Lecture 2 keyword of C Programming LanguageSURAJ KUMAR
 
C Programming Language Step by Step Part 3
C Programming Language Step by Step Part 3C Programming Language Step by Step Part 3
C Programming Language Step by Step Part 3Rumman Ansari
 

Similar to C language basics (20)

C language
C languageC language
C language
 
Token and operators
Token and operatorsToken and operators
Token and operators
 
Data type in c
Data type in cData type in c
Data type in c
 
Chapter 2: Elementary Programming
Chapter 2: Elementary ProgrammingChapter 2: Elementary Programming
Chapter 2: Elementary Programming
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptx
 
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
 
Data type2 c
Data type2 cData type2 c
Data type2 c
 
Learn C LANGUAGE at ASIT
Learn C LANGUAGE at ASITLearn C LANGUAGE at ASIT
Learn C LANGUAGE at ASIT
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variables
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2
 
01 Java Language And OOP PART I
01 Java Language And OOP PART I01 Java Language And OOP PART I
01 Java Language And OOP PART I
 
C language
C languageC language
C language
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
Lecture 2 keyword of C Programming Language
Lecture 2 keyword of C Programming LanguageLecture 2 keyword of C Programming Language
Lecture 2 keyword of C Programming Language
 
SPL 5 | scanf in C
SPL 5 | scanf in CSPL 5 | scanf in C
SPL 5 | scanf in C
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
C Programming Language Step by Step Part 3
C Programming Language Step by Step Part 3C Programming Language Step by Step Part 3
C Programming Language Step by Step Part 3
 

Recently uploaded

Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 

Recently uploaded (20)

Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 

C language basics

  • 1. Basics of C language.Basics of C language. Tokens in C Basic data types Constants and variables.
  • 2. Tokens in CTokens 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. http://www.fita.in/c-c-training-in-chennai/
  • 3. Tokens in CTokens in C 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. http://www.fita.in/c-c-training-in-chennai/
  • 4. Basic Data TypesBasic Data TypesIntegral Types ◦ Integers are stored in various sizes. They can be signed or unsigned. ◦ Example Suppose an integer is represented by a byte (8 bits). Leftmost bit is sign bit. If the sign bit is 0, the number is treated as positive. Bit pattern 01001011 = 75 (decimal). The largest positive number is 01111111 = 27 – 1 = 127. Negative numbers are stored as two’s complement or as one’s complement. -75 = 10110100 (one’s complement). -75 = 10110101 (two’s complement). http://www.fita.in/c-c-training-in-chennai/
  • 5. Basic Data TypesBasic 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 http://www.fita.in/c-c-training-in-chennai/
  • 6. Basic Data TypesBasic Data Types 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. http://www.fita.in/c-c-training-in-chennai/
  • 7. ConstantsConstantsNumerical Constants ◦ Constants like 12, 253 are stored as int type. No decimal point. ◦ 12L or 12l are stored as long int. ◦ 12U or 12u are stored as unsigned int. ◦ 12UL or 12ul are stored as unsigned long int. ◦ Numbers with a decimal point (12.34) are stored as double. ◦ Numbers with exponent (12e-3 = 12 x 10-3 ) are stored as double. ◦ 12.34f or 1.234e1f are stored as float. ◦ These are not valid constants: 25,000 7.1e 4 $200 2.3e-3.4 etc. http://www.fita.in/c-c-training-in-chennai/
  • 8. ConstantsConstants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” http://www.fita.in/c-c-training-in-chennai/
  • 9. VariablesVariables Naming a Variable ◦ Must be a valid identifier. ◦ Must not be a keyword ◦ Names are case sensitive. ◦ Variables are identified by only first 32 characters. ◦ Library commonly uses names beginning with _. ◦ Naming Styles: Uppercase style and Underscore style ◦ lowerLimit lower_limit ◦ incomeTax income_tax http://www.fita.in/c-c-training-in-chennai/
  • 10. DeclarationsDeclarations 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; http://www.fita.in/c-c-training-in-chennai/
  • 11. Global and Local VariablesGlobal and Local Variables Global Variables ◦ These variables are declared outside all functions. ◦ Life time of a global variable is the entire execution period of the program. ◦ Can be accessed by any function defined below the declaration, in a file. /* Compute Area and Perimeter of a circle */ #include <stdio.h> float pi = 3.14159; /* Global */ main() { float rad; /* Local */ printf( “Enter the radius “ ); scanf(“%f” , &rad); if ( rad > 0.0 ) { float area = pi * rad * rad; float peri = 2 * pi * rad; printf( “Area = %fn” , area ); printf( “Peri = %fn” , peri ); } else printf( “Negative radiusn”); printf( “Area = %fn” , area ); } /* Compute Area and Perimeter of a circle */ #include <stdio.h> float pi = 3.14159; /* Global */ main() { float rad; /* Local */ printf( “Enter the radius “ ); scanf(“%f” , &rad); if ( rad > 0.0 ) { float area = pi * rad * rad; float peri = 2 * pi * rad; printf( “Area = %fn” , area ); printf( “Peri = %fn” , peri ); } else printf( “Negative radiusn”); printf( “Area = %fn” , area ); } http://www.fita.in/c-c-training-in-chennai/
  • 12. Global and Local VariablesGlobal and Local Variables Local Variables ◦ These variables are declared inside some functions. ◦ Life time of a local variable is the entire execution period of the function in which it is defined. ◦ Cannot be accessed by any other function. ◦ In general variables declared inside a block are accessible only in that block. /* Compute Area and Perimeter of a circle */ #include <stdio.h> float pi = 3.14159; /* Global */ main() { float rad; /* Local */ printf( “Enter the radius “ ); scanf(“%f” , &rad); if ( rad > 0.0 ) { float area = pi * rad * rad; float peri = 2 * pi * rad; printf( “Area = %fn” , area ); printf( “Peri = %fn” , peri ); } else printf( “Negative radiusn”); printf( “Area = %fn” , area ); } /* Compute Area and Perimeter of a circle */ #include <stdio.h> float pi = 3.14159; /* Global */ main() { float rad; /* Local */ printf( “Enter the radius “ ); scanf(“%f” , &rad); if ( rad > 0.0 ) { float area = pi * rad * rad; float peri = 2 * pi * rad; printf( “Area = %fn” , area ); printf( “Peri = %fn” , peri ); } else printf( “Negative radiusn”); printf( “Area = %fn” , area ); } http://www.fita.in/c-c-training-in-chennai/

Editor's Notes

  1. C guarantees only following: Sizeof(short) &amp;lt;= sizeof(int) &amp;lt;= sizeof(long).