SlideShare a Scribd company logo
Lecture02(Constants, variable & data types)
June 15, 2010
       Today's Outline
          Data Types
          C Tokens
          Keywords & Identifiers
          Constants
          Variables
          The four C scopes
          Type Qualifiers
          Storage Class Specifiers




  Md. Mahbub Alam      Structured Programming Language   1
                                  (CSE-1121)
C Tokens
Token: Smallest individual units in C program are known as token.
  e.g. Keywords - int, break, for, struct etc
       Identifiers - count, amount etc
       Constants - 10, 5.5, -7.5 etc
       Strings - “DUET”, “1st Year” etc
       Operators - +, -, *, /
       Special Symbols - [] {} etc




 Md. Mahbub Alam       Structured Programming Language      2
                                  (CSE-1121)
C Data Types
  All C compiler supports 5 foundational data types, namely
integer(int), floating-point(float), double precision floating-point
(double), character(char), & void.
                     Data Type Size (bits)
                        char               8
                        int           16 or 32
                       float              32
                      double              64

  void type either explicitly declares a function as returning no value
or creates generic pointers.




   Md. Mahbub Alam            Structured Programming Language          3
                                         (CSE-1121)
C Keywords
  All keywords have fixed meanings & these meanings can not be
changed. Serve as basic building blocks for program statements.
 All keyword must be written in lowercase letters.
• Flow control (6) - if, else, return, switch, case,
  default
• Loops (5) - for, do, while, break, continue
• Common types (5) - int, float, double, char, void
• Structures (3) - struct, typedef, union
• Counting and sizing things (2) - enum, sizeof
• Rare but still useful types (7) - extern, signed,unsigned,
  long, short, static, const
• Evil keywords which we avoid (1) - goto
• Others (3) - auto, register, volatile
   Md. Mahbub Alam     Structured Programming Language        4
                                  (CSE-1121)
C Identifiers
 In C, the names of variables, functions, labels & various other user-
defined items are called identifiers.
 Rules for identifiers:
   • First character must be an alphabet or underscore and subsequent characters
   must be either letter, digits, or underscore.
   • Only 31 characters are significant.
   • Can not be the same as a C keywords & should not have the same name as
   functions that are in C library.
   • Must not contain white space.




   Md. Mahbub Alam          Structured Programming Language                 5
                                       (CSE-1121)
Variables
  A variable is a named location in memory that is used to hold a value
that can be modified by the program.
 All variable must be declared before they can be used.
        Format: type varable_name; e.g. int count;

 Variable name must be meaningful to reflect its function or nature.
 Variable initializations Format: type variable_name = constant;
 Where variables to be declared:
         - Inside function (local variables)
         - In the definition of function parameters (Formal parameters)
         - Outside of all functions (global variables)

   Md. Mahbub Alam       Structured Programming Language           6
                                    (CSE-1121)
Constants
  Constants refers to fixed values that do not change during program
execution.
 Constants can be of any type of the basic types.
 Constants are also called literals.
                             int                10, 135, -23
 Example:
                          long int               5678349L
                        unisigned int              580U
                     unisigned long int         9845464UL
                            float                 120.25f
                        long double              1020.75L
                     character constants            ‘D’
                           string                 “DUET”
                           HEX                     0x80
                           Octal                    016

   Md. Mahbub Alam            Structured Programming Language   7
                                         (CSE-1121)
Backslash Character Constants
Backslash character constants are used in output functions.
Also known as escape sequence
                   Code                      Meaning
                    b    Backspace
                    n    New line
                    f    Form feed
                    r    Carriage return
                    t    Horizontal tab
                    v    Vertical tab
                    ”    Double quote
                    ’    Single quote
                        Backslash
                    a    Alert
                    ?    Question mark
                    0    Null
 Md. Mahbub Alam                  Structured Programming Language   8
                                             (CSE-1121)
Any Question?




Md. Mahbub Alam   Structured Programming Language   9
                             (CSE-1121)
Thank You All




Md. Mahbub Alam     Structured Programming Language   10
                               (CSE-1121)

More Related Content

What's hot

Character set of c
Character set of cCharacter set of c
Character set of c
Chandrapriya Rediex
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
programming9
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
Rumman Ansari
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
Mahender Boda
 
Chapter1 c programming data types, variables and constants
Chapter1 c programming   data types, variables and constantsChapter1 c programming   data types, variables and constants
Chapter1 c programming data types, variables and constantsvinay arora
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
raksharao
 
Constant and variacles in c
Constant   and variacles in cConstant   and variacles in c
Constant and variacles in c
yash patel
 
Constants and variables in c programming
Constants and variables in c programmingConstants and variables in c programming
Constants and variables in c programming
Chitrank Dixit
 
Data types
Data typesData types
Data types
Nokesh Prabhakar
 
C data types, arrays and structs
C data types, arrays and structsC data types, arrays and structs
C data types, arrays and structs
Saad Sheikh
 
3 data-types-in-c
3 data-types-in-c3 data-types-in-c
3 data-types-in-c
teach4uin
 
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
MOHIT TOMAR
 
Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++
Neeru Mittal
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data typesManisha Keim
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variablesTony Apreku
 
C presentation book
C presentation bookC presentation book
C presentation book
krunal1210
 
Data types in java | What is Datatypes in Java | Learning with RD | Created b...
Data types in java | What is Datatypes in Java | Learning with RD | Created b...Data types in java | What is Datatypes in Java | Learning with RD | Created b...
Data types in java | What is Datatypes in Java | Learning with RD | Created b...
rahuldaredia21
 
Complete Tokens in c/c++
Complete Tokens in c/c++Complete Tokens in c/c++
Complete Tokens in c/c++
Shobi P P
 

What's hot (20)

Character set of c
Character set of cCharacter set of c
Character set of c
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
Chapter1 c programming data types, variables and constants
Chapter1 c programming   data types, variables and constantsChapter1 c programming   data types, variables and constants
Chapter1 c programming data types, variables and constants
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
 
Constant and variacles in c
Constant   and variacles in cConstant   and variacles in c
Constant and variacles in c
 
Constants and variables in c programming
Constants and variables in c programmingConstants and variables in c programming
Constants and variables in c programming
 
Data types
Data typesData types
Data types
 
C data types, arrays and structs
C data types, arrays and structsC data types, arrays and structs
C data types, arrays and structs
 
3 data-types-in-c
3 data-types-in-c3 data-types-in-c
3 data-types-in-c
 
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
 
Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
 
C presentation book
C presentation bookC presentation book
C presentation book
 
Data types in java | What is Datatypes in Java | Learning with RD | Created b...
Data types in java | What is Datatypes in Java | Learning with RD | Created b...Data types in java | What is Datatypes in Java | Learning with RD | Created b...
Data types in java | What is Datatypes in Java | Learning with RD | Created b...
 
Data types
Data typesData types
Data types
 
Complete Tokens in c/c++
Complete Tokens in c/c++Complete Tokens in c/c++
Complete Tokens in c/c++
 

Viewers also liked

08-Airport Configuration-1 ( Highway and Airport Engineering Dr. Sherif El-Ba...
08-Airport Configuration-1 ( Highway and Airport Engineering Dr. Sherif El-Ba...08-Airport Configuration-1 ( Highway and Airport Engineering Dr. Sherif El-Ba...
08-Airport Configuration-1 ( Highway and Airport Engineering Dr. Sherif El-Ba...
Hossam Shafiq I
 
Traffic Forecasting (Transportation Engineering)
Traffic Forecasting (Transportation Engineering)Traffic Forecasting (Transportation Engineering)
Traffic Forecasting (Transportation Engineering)
Hossam Shafiq I
 
Freeway LOS (Transportation Engineering)
Freeway LOS (Transportation Engineering)Freeway LOS (Transportation Engineering)
Freeway LOS (Transportation Engineering)
Hossam Shafiq I
 
Lecture 2: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 2: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr Lecture 2: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 2: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Hossam Shafiq I
 
Traffic Detection Systems (Transportation Engineering)
Traffic Detection Systems (Transportation Engineering)Traffic Detection Systems (Transportation Engineering)
Traffic Detection Systems (Transportation Engineering)
Hossam Shafiq I
 
Vehicle Dynamics (Transportation Engineering)
Vehicle Dynamics (Transportation Engineering)Vehicle Dynamics (Transportation Engineering)
Vehicle Dynamics (Transportation Engineering)
Hossam Shafiq I
 
06-Traffic Characterization ( Highway and Airport Engineering Dr. Sherif El-B...
06-Traffic Characterization ( Highway and Airport Engineering Dr. Sherif El-B...06-Traffic Characterization ( Highway and Airport Engineering Dr. Sherif El-B...
06-Traffic Characterization ( Highway and Airport Engineering Dr. Sherif El-B...
Hossam Shafiq I
 
07-Structural Design ( Highway and Airport Engineering Dr. Sherif El-Badawy )
07-Structural Design ( Highway and Airport Engineering Dr. Sherif El-Badawy )07-Structural Design ( Highway and Airport Engineering Dr. Sherif El-Badawy )
07-Structural Design ( Highway and Airport Engineering Dr. Sherif El-Badawy )
Hossam Shafiq I
 
Traffi speed study on panthapath to russel square by pronob ghosh buet 1204011
Traffi speed study on panthapath to russel square by pronob ghosh buet 1204011Traffi speed study on panthapath to russel square by pronob ghosh buet 1204011
Traffi speed study on panthapath to russel square by pronob ghosh buet 1204011
Pronob Ghosh
 
Traffic volume study on panthapath to russel square by pronob ghosh buet 1204011
Traffic volume study on panthapath to russel square by pronob ghosh buet 1204011Traffic volume study on panthapath to russel square by pronob ghosh buet 1204011
Traffic volume study on panthapath to russel square by pronob ghosh buet 1204011
Pronob Ghosh
 
Soil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-Agha
Soil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-AghaSoil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-Agha
Soil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-Agha
Hossam Shafiq I
 
Lecture 6: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 6: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa GabrLecture 6: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 6: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Hossam Shafiq I
 
09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )
09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )
09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )
Hossam Shafiq I
 
Lecture 5: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 5:  Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa GabrLecture 5:  Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 5: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Hossam Shafiq I
 
Parking design in front of CE building BUET by Pronob ghosh 1204011
Parking design in front of CE building BUET by Pronob ghosh 1204011Parking design in front of CE building BUET by Pronob ghosh 1204011
Parking design in front of CE building BUET by Pronob ghosh 1204011
Pronob Ghosh
 
03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...
03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...
03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...
Hossam Shafiq I
 
28 pavement design
28 pavement design28 pavement design
28 pavement design
AHMED NADIM JILANI
 
02-Aggregate ( Highway and Airport Engineering Dr. Sherif El-Badawy )
02-Aggregate ( Highway and Airport Engineering Dr. Sherif El-Badawy )02-Aggregate ( Highway and Airport Engineering Dr. Sherif El-Badawy )
02-Aggregate ( Highway and Airport Engineering Dr. Sherif El-Badawy )
Hossam Shafiq I
 
Geometry condition study on panthapath to russel square by pronob ghosh buet ...
Geometry condition study on panthapath to russel square by pronob ghosh buet ...Geometry condition study on panthapath to russel square by pronob ghosh buet ...
Geometry condition study on panthapath to russel square by pronob ghosh buet ...
Pronob Ghosh
 

Viewers also liked (20)

08-Airport Configuration-1 ( Highway and Airport Engineering Dr. Sherif El-Ba...
08-Airport Configuration-1 ( Highway and Airport Engineering Dr. Sherif El-Ba...08-Airport Configuration-1 ( Highway and Airport Engineering Dr. Sherif El-Ba...
08-Airport Configuration-1 ( Highway and Airport Engineering Dr. Sherif El-Ba...
 
Traffic Forecasting (Transportation Engineering)
Traffic Forecasting (Transportation Engineering)Traffic Forecasting (Transportation Engineering)
Traffic Forecasting (Transportation Engineering)
 
Freeway LOS (Transportation Engineering)
Freeway LOS (Transportation Engineering)Freeway LOS (Transportation Engineering)
Freeway LOS (Transportation Engineering)
 
Lecture 2: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 2: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr Lecture 2: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 2: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
 
Lecture05(control structure part ii)
Lecture05(control structure part ii)Lecture05(control structure part ii)
Lecture05(control structure part ii)
 
Traffic Detection Systems (Transportation Engineering)
Traffic Detection Systems (Transportation Engineering)Traffic Detection Systems (Transportation Engineering)
Traffic Detection Systems (Transportation Engineering)
 
Vehicle Dynamics (Transportation Engineering)
Vehicle Dynamics (Transportation Engineering)Vehicle Dynamics (Transportation Engineering)
Vehicle Dynamics (Transportation Engineering)
 
06-Traffic Characterization ( Highway and Airport Engineering Dr. Sherif El-B...
06-Traffic Characterization ( Highway and Airport Engineering Dr. Sherif El-B...06-Traffic Characterization ( Highway and Airport Engineering Dr. Sherif El-B...
06-Traffic Characterization ( Highway and Airport Engineering Dr. Sherif El-B...
 
07-Structural Design ( Highway and Airport Engineering Dr. Sherif El-Badawy )
07-Structural Design ( Highway and Airport Engineering Dr. Sherif El-Badawy )07-Structural Design ( Highway and Airport Engineering Dr. Sherif El-Badawy )
07-Structural Design ( Highway and Airport Engineering Dr. Sherif El-Badawy )
 
Traffi speed study on panthapath to russel square by pronob ghosh buet 1204011
Traffi speed study on panthapath to russel square by pronob ghosh buet 1204011Traffi speed study on panthapath to russel square by pronob ghosh buet 1204011
Traffi speed study on panthapath to russel square by pronob ghosh buet 1204011
 
Traffic volume study on panthapath to russel square by pronob ghosh buet 1204011
Traffic volume study on panthapath to russel square by pronob ghosh buet 1204011Traffic volume study on panthapath to russel square by pronob ghosh buet 1204011
Traffic volume study on panthapath to russel square by pronob ghosh buet 1204011
 
Soil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-Agha
Soil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-AghaSoil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-Agha
Soil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-Agha
 
Lecture 6: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 6: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa GabrLecture 6: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 6: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
 
09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )
09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )
09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )
 
Lecture 5: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 5:  Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa GabrLecture 5:  Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 5: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
 
Parking design in front of CE building BUET by Pronob ghosh 1204011
Parking design in front of CE building BUET by Pronob ghosh 1204011Parking design in front of CE building BUET by Pronob ghosh 1204011
Parking design in front of CE building BUET by Pronob ghosh 1204011
 
03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...
03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...
03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...
 
28 pavement design
28 pavement design28 pavement design
28 pavement design
 
02-Aggregate ( Highway and Airport Engineering Dr. Sherif El-Badawy )
02-Aggregate ( Highway and Airport Engineering Dr. Sherif El-Badawy )02-Aggregate ( Highway and Airport Engineering Dr. Sherif El-Badawy )
02-Aggregate ( Highway and Airport Engineering Dr. Sherif El-Badawy )
 
Geometry condition study on panthapath to russel square by pronob ghosh buet ...
Geometry condition study on panthapath to russel square by pronob ghosh buet ...Geometry condition study on panthapath to russel square by pronob ghosh buet ...
Geometry condition study on panthapath to russel square by pronob ghosh buet ...
 

Similar to Lecture02(constants, variable & data types)

Msc prev completed
Msc prev completedMsc prev completed
Msc prev completed
mshoaib15
 
Msc prev updated
Msc prev updatedMsc prev updated
Msc prev updated
mshoaib15
 
Lecture 01 2017
Lecture 01 2017Lecture 01 2017
Lecture 01 2017
Jesmin Akhter
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
Preeti Kashyap
 
cmp104 lec 8
cmp104 lec 8cmp104 lec 8
cmp104 lec 8kapil078
 
Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)
Nuzhat Memon
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
amol_chavan
 
venkatesh.pptx
venkatesh.pptxvenkatesh.pptx
venkatesh.pptx
KishoreRedla
 
Features and Fundamentals of C Language for Beginners
Features and Fundamentals of C Language for BeginnersFeatures and Fundamentals of C Language for Beginners
Features and Fundamentals of C Language for Beginners
Chandrakant Divate
 
7986-lect 7.pdf
7986-lect 7.pdf7986-lect 7.pdf
7986-lect 7.pdf
RiazAhmad521284
 
C
CC
C PADHLO FRANDS.pdf
C PADHLO FRANDS.pdfC PADHLO FRANDS.pdf
C PADHLO FRANDS.pdf
RishiBhardwaj65
 
Cpu
CpuCpu
SPC Unit 2
SPC Unit 2SPC Unit 2
SPC Unit 2
SIMONTHOMAS S
 
C PROGRAMMING LANGUAGE.pptx
 C PROGRAMMING LANGUAGE.pptx C PROGRAMMING LANGUAGE.pptx
C PROGRAMMING LANGUAGE.pptx
AnshSrivastava48
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
Muthuselvam RS
 
C programming.pdf
C programming.pdfC programming.pdf
C programming.pdf
JitendraYadav351971
 

Similar to Lecture02(constants, variable & data types) (20)

Msc prev completed
Msc prev completedMsc prev completed
Msc prev completed
 
Msc prev updated
Msc prev updatedMsc prev updated
Msc prev updated
 
Lecture 01 2017
Lecture 01 2017Lecture 01 2017
Lecture 01 2017
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
cmp104 lec 8
cmp104 lec 8cmp104 lec 8
cmp104 lec 8
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
Chap 1 and 2
Chap 1 and 2Chap 1 and 2
Chap 1 and 2
 
Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
venkatesh.pptx
venkatesh.pptxvenkatesh.pptx
venkatesh.pptx
 
Features and Fundamentals of C Language for Beginners
Features and Fundamentals of C Language for BeginnersFeatures and Fundamentals of C Language for Beginners
Features and Fundamentals of C Language for Beginners
 
7986-lect 7.pdf
7986-lect 7.pdf7986-lect 7.pdf
7986-lect 7.pdf
 
Chtp408
Chtp408Chtp408
Chtp408
 
C
CC
C
 
C PADHLO FRANDS.pdf
C PADHLO FRANDS.pdfC PADHLO FRANDS.pdf
C PADHLO FRANDS.pdf
 
Cpu
CpuCpu
Cpu
 
SPC Unit 2
SPC Unit 2SPC Unit 2
SPC Unit 2
 
C PROGRAMMING LANGUAGE.pptx
 C PROGRAMMING LANGUAGE.pptx C PROGRAMMING LANGUAGE.pptx
C PROGRAMMING LANGUAGE.pptx
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
 
C programming.pdf
C programming.pdfC programming.pdf
C programming.pdf
 

Recently uploaded

Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 

Recently uploaded (20)

Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 

Lecture02(constants, variable & data types)

  • 1. Lecture02(Constants, variable & data types) June 15, 2010 Today's Outline Data Types C Tokens Keywords & Identifiers Constants Variables The four C scopes Type Qualifiers Storage Class Specifiers Md. Mahbub Alam Structured Programming Language 1 (CSE-1121)
  • 2. C Tokens Token: Smallest individual units in C program are known as token. e.g. Keywords - int, break, for, struct etc Identifiers - count, amount etc Constants - 10, 5.5, -7.5 etc Strings - “DUET”, “1st Year” etc Operators - +, -, *, / Special Symbols - [] {} etc Md. Mahbub Alam Structured Programming Language 2 (CSE-1121)
  • 3. C Data Types All C compiler supports 5 foundational data types, namely integer(int), floating-point(float), double precision floating-point (double), character(char), & void. Data Type Size (bits) char 8 int 16 or 32 float 32 double 64 void type either explicitly declares a function as returning no value or creates generic pointers. Md. Mahbub Alam Structured Programming Language 3 (CSE-1121)
  • 4. C Keywords All keywords have fixed meanings & these meanings can not be changed. Serve as basic building blocks for program statements. All keyword must be written in lowercase letters. • Flow control (6) - if, else, return, switch, case, default • Loops (5) - for, do, while, break, continue • Common types (5) - int, float, double, char, void • Structures (3) - struct, typedef, union • Counting and sizing things (2) - enum, sizeof • Rare but still useful types (7) - extern, signed,unsigned, long, short, static, const • Evil keywords which we avoid (1) - goto • Others (3) - auto, register, volatile Md. Mahbub Alam Structured Programming Language 4 (CSE-1121)
  • 5. C Identifiers In C, the names of variables, functions, labels & various other user- defined items are called identifiers. Rules for identifiers: • First character must be an alphabet or underscore and subsequent characters must be either letter, digits, or underscore. • Only 31 characters are significant. • Can not be the same as a C keywords & should not have the same name as functions that are in C library. • Must not contain white space. Md. Mahbub Alam Structured Programming Language 5 (CSE-1121)
  • 6. Variables A variable is a named location in memory that is used to hold a value that can be modified by the program. All variable must be declared before they can be used. Format: type varable_name; e.g. int count; Variable name must be meaningful to reflect its function or nature. Variable initializations Format: type variable_name = constant; Where variables to be declared: - Inside function (local variables) - In the definition of function parameters (Formal parameters) - Outside of all functions (global variables) Md. Mahbub Alam Structured Programming Language 6 (CSE-1121)
  • 7. Constants Constants refers to fixed values that do not change during program execution. Constants can be of any type of the basic types. Constants are also called literals. int 10, 135, -23 Example: long int 5678349L unisigned int 580U unisigned long int 9845464UL float 120.25f long double 1020.75L character constants ‘D’ string “DUET” HEX 0x80 Octal 016 Md. Mahbub Alam Structured Programming Language 7 (CSE-1121)
  • 8. Backslash Character Constants Backslash character constants are used in output functions. Also known as escape sequence Code Meaning b Backspace n New line f Form feed r Carriage return t Horizontal tab v Vertical tab ” Double quote ’ Single quote Backslash a Alert ? Question mark 0 Null Md. Mahbub Alam Structured Programming Language 8 (CSE-1121)
  • 9. Any Question? Md. Mahbub Alam Structured Programming Language 9 (CSE-1121)
  • 10. Thank You All Md. Mahbub Alam Structured Programming Language 10 (CSE-1121)