SlideShare a Scribd company logo
Lectures on Busy Bee Workshop 1
DATA TYPE IN CDATA TYPE IN C
This session Outline
Tokens
Data Types
Statements Types
Lectures on Busy Bee Workshop 2
Tokens in CTokens in C
5 Tokens
1. Keywords
2. Identifiers
3. Constants/Literals
4. Operators
5. White Spaces/Other symbols
Basic elements for building a program
Lectures on Busy Bee Workshop 3
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/Literals
Constants like 13, ‘a’, 1.3e-5, “Raj” etc.
Integer constant
Character constant
String constant
Float or Real constant
Lectures on Busy Bee Workshop 4
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,
keywords and constants.
Lectures on Busy Bee Workshop 5
Tokens in C - ExampleTokens in C - Example
void main()
{
int a=25;
float b=45.0;
char c='A';
float sum;
sum=a+b+c;
printf("Result =%fn",sum);
}
What will be the output?
Tokens
Keywords?
Identifiers?
Constants?
Operators?
Symbols?
Lectures on Busy Bee Workshop 6
Basic Data TypesBasic Data Types
Data types are used to indicate the nature
and size of the data.
Data Type Nature Size Range
char Character constant 1 Byte – 8 bits -128 to 127
int Integer constant 2 Bytes – 16 bits -32768 to 32767
float Real constant 4 Bytes – 32 bits 3.4 * (10**-38) to
3.4 * (10**+38)
double Real constant 8 Bytes – 64 bits 1.7 * (10**-308) to
1.7 * (10**+308)
Type Modifiers - signed, unsigned, short, and long
A type modifier alters the meaning of the base data type to yield a
new type.
Lectures on Busy Bee Workshop 7
Data TypesData Types
Integral data types – Numbers without decimal point
char / signed char Stored as 8 bits. Unsigned 0 to 255.
unsigned char Signed -128 to 127.
int /signed int Stored as 16 bits. Unsigned 0 to 65535.
unsigned int Signed -32768 to 32767.
short int Same as int.
long / long int Stored as 32 bits. Unsigned 0 to 4294967295.
signed long /signed long int Signed -2147483648 to 2147483647
unsigned long int
All of the type modifiers can be applied to the base type int.
signed and unsigned can also be applied to the base type char.
Control String/Format Specifier
– %c, %h, %d, %l, %u, %ul
These are not valid constants: ?
25,000 7.1e 4 $200 2.3e-3.4 etc.
Lectures on Busy Bee Workshop 8
Data TypesData Types
Floating Point Numbers
Floating point numbers are rational numbers. Always signed numbers. i.e
Numbers with decimal point.
float
• Typically stored in 4 bytes(32 bits)
• Range - 3.4 * (10**-38) to 3.4 * (10**+38)
Double
• Typically stored in 8 bytes(64 bits)
• Range - 1.7 * (10**-308) to 1.7 * (10**+308).
Long double
• Typically stored in 10 bytes (80 bits)
• Range - 3.4 * (10**-4932) to 1.1 * (10**+4932)
Control String/Format Specifier
– %f, %e, %lf
Lectures on Busy Bee Workshop 9
Data TypesData Types
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”
Lectures on Busy Bee Workshop 10
Data TypesData Types
Character and String data types
char /signed char/unsigned char
• Typically stored in 1 byte(8 bits)
• Range – signed -128 to 127, unsigned 0 to 255
char name[20] – Character Array
• Above example occupy 20 bytes to store maximum of 20 characters
of any one name.
• char name[5][20] – Store any five name, each name have
maximum of 20 letters each.
Control String/Format Specifier
– %c, %s
Lectures on Busy Bee Workshop 11
Data Types - SummaryData Types - Summary
Data Types Length Range
unsigned char 8 bits 0 to 255
char 8 bits -128 to 127
unsigned int 16 bits 0 to 65,535
short int 16 bits -32,768 to 32,767
int 16 bits -32,768 to 32,767
enum 16 bits -32,768 to 32,767
unsigned long 32 bits 0 to 4,294,967,295
long 32 bits -2,147,483,648 to 2,147,483,647
float 32 bits 3.4 * (10**-38) to 3.4 * (10**+38)
double 64 bits 1.7 * (10**-308) to 1.7 * (10**+308)
long double 80 bits 3.4 * (10**-4932) to 1.1 * (10**+4932)
Lectures on Busy Bee Workshop 12
enum & typedef Typeenum & typedef Type
Enum
Defines a set of constants of type int.
Example:
enum modes { LASTMODE = -1, BW40 = 0, C40, BW80, C80,
MONO = 7 };
Here "modes" is the type tag. "LASTMODE", "BW40",
"C40", etc. are the constant names. The
value of C40 is 1 (BW40 + 1); BW80 = 2 (C40
+ 1), etc.
typedef
Define a new data type using existing types
Example :
typedef int Number;
typedef char String[20];
Lectures on Busy Bee Workshop 13
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
Lectures on Busy Bee Workshop 14
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;
Lectures on Busy Bee Workshop 15
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 );
}
Lectures on Busy Bee Workshop 16
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 );
}
Statement TypesStatement Types
Input Statements – scanf(), getchar(), gets() etc
Output Statements – printf(), putchar(), puts() etc
Declaration Statement – Datatype variablelist;
Assignment Statements - variable=expression;/(=,+=,-+,*=,/=)
Control statements – if, if …else, nested if, switch
Iteration statements – for, while, do while
Lectures on Busy Bee Workshop 17
Try this in lab sessionTry this in lab session
Program for print the memory allocation of all
data types.
Program for print your address label.
Program for add this two number 1,20,000 and
80,500.
Write a program to illustrate enum & typedef.
Rewrite Program 2 for statements illustration (i.e
Get any number <5, 1 time, or 2 time.
Lectures on Busy Bee Workshop 18
1. Know the date type size
2. Flow control, tokens
3. Size limit, control string
4. enum & typedef
5. Statements
Data type2 c
Data type2 c

More Related Content

What's hot

Programming with Python
Programming with PythonProgramming with Python
Programming with Python
Rasan Samarasinghe
 
Presentation 5th
Presentation 5thPresentation 5th
Presentation 5thConnex
 
Python basics
Python basicsPython basics
Python basics
Manisha Gholve
 
String & its application
String & its applicationString & its application
String & its applicationTech_MX
 
C Programming Unit-3
C Programming Unit-3C Programming Unit-3
C Programming Unit-3
Vikram Nandini
 
Unit4 Slides
Unit4 SlidesUnit4 Slides
Unit4 Slides
Rakesh Roshan
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programming
nmahi96
 
C Programming Assignment
C Programming AssignmentC Programming Assignment
C Programming Assignment
Vijayananda Mohire
 
String notes
String notesString notes
String notes
Prasadu Peddi
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
Saifur Rahman
 
Assignment c programming
Assignment c programmingAssignment c programming
Assignment c programming
Icaii Infotech
 
Advanced C programming
Advanced C programmingAdvanced C programming
Advanced C programming
Claus Wu
 
C# Strings
C# StringsC# Strings
C# Strings
Hock Leng PUAH
 
Strings in C
Strings in CStrings in C
Strings in C
Kamal Acharya
 
The string class
The string classThe string class
The string class
Syed Zaid Irshad
 
Chapter Eight(2)
Chapter Eight(2)Chapter Eight(2)
Chapter Eight(2)bolovv
 
String in programming language in c or c++
 String in programming language  in c or c++  String in programming language  in c or c++
String in programming language in c or c++
Samsil Arefin
 
Strings in python
Strings in pythonStrings in python
Strings in python
Prabhakaran V M
 

What's hot (20)

Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Presentation 5th
Presentation 5thPresentation 5th
Presentation 5th
 
Python basics
Python basicsPython basics
Python basics
 
String & its application
String & its applicationString & its application
String & its application
 
C Programming Unit-3
C Programming Unit-3C Programming Unit-3
C Programming Unit-3
 
Unit4 Slides
Unit4 SlidesUnit4 Slides
Unit4 Slides
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programming
 
C Programming Assignment
C Programming AssignmentC Programming Assignment
C Programming Assignment
 
String notes
String notesString notes
String notes
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
 
Assignment c programming
Assignment c programmingAssignment c programming
Assignment c programming
 
Advanced C programming
Advanced C programmingAdvanced C programming
Advanced C programming
 
C# Strings
C# StringsC# Strings
C# Strings
 
Strings in C
Strings in CStrings in C
Strings in C
 
The string class
The string classThe string class
The string class
 
Chapter Eight(2)
Chapter Eight(2)Chapter Eight(2)
Chapter Eight(2)
 
05 c++-strings
05 c++-strings05 c++-strings
05 c++-strings
 
String in programming language in c or c++
 String in programming language  in c or c++  String in programming language  in c or c++
String in programming language in c or c++
 
Strings in python
Strings in pythonStrings in python
Strings in python
 
Strings
StringsStrings
Strings
 

Viewers also liked

CV Wageh Khedr - pdf.
CV  Wageh Khedr - pdf.CV  Wageh Khedr - pdf.
CV Wageh Khedr - pdf.wagieh kheder
 
ICI final
ICI finalICI final
ICI final
Lam Yu
 
Course outline august 2015 (1)
Course outline august 2015 (1)Course outline august 2015 (1)
Course outline august 2015 (1)
Lam Yu
 
Master thesis Lies Polet
Master thesis Lies PoletMaster thesis Lies Polet
Master thesis Lies PoletLies Polet
 
Project 2
Project 2Project 2
Project 2
Lam Yu
 
File handling-c programming language
File handling-c programming languageFile handling-c programming language
File handling-c programming language
thirumalaikumar3
 
CWendland NCUR Research Paper Submission
CWendland NCUR Research Paper SubmissionCWendland NCUR Research Paper Submission
CWendland NCUR Research Paper SubmissionChristian Wendland, MHA
 
Cts module outline handout 11082015_v01
Cts module outline handout 11082015_v01Cts module outline handout 11082015_v01
Cts module outline handout 11082015_v01
Lam Yu
 
Essay question august2015 (1)
Essay question august2015 (1)Essay question august2015 (1)
Essay question august2015 (1)
Lam Yu
 
Epc123 (1)
Epc123 (1)Epc123 (1)
Epc123 (1)
Lam Yu
 
32 docynormas normasapa
32 docynormas normasapa32 docynormas normasapa
32 docynormas normasapa
Angie Martinez Benavides
 
File handling in c
File  handling in cFile  handling in c
File handling in c
thirumalaikumar3
 
Olmedo, rodrigo. Liderazgo
Olmedo, rodrigo. LiderazgoOlmedo, rodrigo. Liderazgo
Olmedo, rodrigo. Liderazgo
Rodrigo Olmedo
 
Tutorial 4(a) (2)
Tutorial 4(a) (2)Tutorial 4(a) (2)
Tutorial 4(a) (2)
Lam Yu
 
Johns Hopkins 2016 MHA Case Competition
Johns Hopkins 2016 MHA Case CompetitionJohns Hopkins 2016 MHA Case Competition
Johns Hopkins 2016 MHA Case Competition
Christian Wendland, MHA
 
Ilmu Pengetahuan
Ilmu PengetahuanIlmu Pengetahuan
Ilmu Pengetahuan
rennijuliyanna
 
Drawing project 1 july 2015_integration (1)
Drawing project 1 july 2015_integration (1)Drawing project 1 july 2015_integration (1)
Drawing project 1 july 2015_integration (1)
Lam Yu
 
Introduction
IntroductionIntroduction
Introduction
Lam Yu
 
Drawing final project studio unit living_july 2015
Drawing final project studio unit living_july 2015Drawing final project studio unit living_july 2015
Drawing final project studio unit living_july 2015
Lam Yu
 
Tutorial 4(b)
Tutorial 4(b)Tutorial 4(b)
Tutorial 4(b)
Lam Yu
 

Viewers also liked (20)

CV Wageh Khedr - pdf.
CV  Wageh Khedr - pdf.CV  Wageh Khedr - pdf.
CV Wageh Khedr - pdf.
 
ICI final
ICI finalICI final
ICI final
 
Course outline august 2015 (1)
Course outline august 2015 (1)Course outline august 2015 (1)
Course outline august 2015 (1)
 
Master thesis Lies Polet
Master thesis Lies PoletMaster thesis Lies Polet
Master thesis Lies Polet
 
Project 2
Project 2Project 2
Project 2
 
File handling-c programming language
File handling-c programming languageFile handling-c programming language
File handling-c programming language
 
CWendland NCUR Research Paper Submission
CWendland NCUR Research Paper SubmissionCWendland NCUR Research Paper Submission
CWendland NCUR Research Paper Submission
 
Cts module outline handout 11082015_v01
Cts module outline handout 11082015_v01Cts module outline handout 11082015_v01
Cts module outline handout 11082015_v01
 
Essay question august2015 (1)
Essay question august2015 (1)Essay question august2015 (1)
Essay question august2015 (1)
 
Epc123 (1)
Epc123 (1)Epc123 (1)
Epc123 (1)
 
32 docynormas normasapa
32 docynormas normasapa32 docynormas normasapa
32 docynormas normasapa
 
File handling in c
File  handling in cFile  handling in c
File handling in c
 
Olmedo, rodrigo. Liderazgo
Olmedo, rodrigo. LiderazgoOlmedo, rodrigo. Liderazgo
Olmedo, rodrigo. Liderazgo
 
Tutorial 4(a) (2)
Tutorial 4(a) (2)Tutorial 4(a) (2)
Tutorial 4(a) (2)
 
Johns Hopkins 2016 MHA Case Competition
Johns Hopkins 2016 MHA Case CompetitionJohns Hopkins 2016 MHA Case Competition
Johns Hopkins 2016 MHA Case Competition
 
Ilmu Pengetahuan
Ilmu PengetahuanIlmu Pengetahuan
Ilmu Pengetahuan
 
Drawing project 1 july 2015_integration (1)
Drawing project 1 july 2015_integration (1)Drawing project 1 july 2015_integration (1)
Drawing project 1 july 2015_integration (1)
 
Introduction
IntroductionIntroduction
Introduction
 
Drawing final project studio unit living_july 2015
Drawing final project studio unit living_july 2015Drawing final project studio unit living_july 2015
Drawing final project studio unit living_july 2015
 
Tutorial 4(b)
Tutorial 4(b)Tutorial 4(b)
Tutorial 4(b)
 

Similar to Data type2 c

Data type in c
Data type in cData type in c
Data type in c
thirumalaikumar3
 
The best every notes on c language is here check it out
The best every notes on c language is here check it outThe best every notes on c language is here check it out
The best every notes on c language is here check it out
rajatryadav22
 
Theory1&amp;2
Theory1&amp;2Theory1&amp;2
Best C++ Programming Homework Help
Best C++ Programming Homework HelpBest C++ Programming Homework Help
Best C++ Programming Homework Help
C++ Homework Help
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
javaTpoint s
 
Pointers and Dynamic Memory Allocation
Pointers and Dynamic Memory AllocationPointers and Dynamic Memory Allocation
Pointers and Dynamic Memory Allocation
Rabin BK
 
Token and operators
Token and operatorsToken and operators
Token and operators
Samsil Arefin
 
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptx
JawadTanvir
 
dinoC_ppt.pptx
dinoC_ppt.pptxdinoC_ppt.pptx
dinoC_ppt.pptx
DinobandhuThokdarCST
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
Bharat Kalia
 
Cbasic
CbasicCbasic
Cbasic
rohitladdu
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptx
vijayapraba1
 
Input output functions
Input output functionsInput output functions
Input output functionshyderali123
 
C language basics
C language basicsC language basics
C language basics
Nikshithas R
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1Shashwat Shriparv
 
Embedded C - Lecture 2
Embedded C - Lecture 2Embedded C - Lecture 2
Embedded C - Lecture 2
Mohamed Abdallah
 
Tut1
Tut1Tut1

Similar to Data type2 c (20)

Data type in c
Data type in cData type in c
Data type in c
 
The best every notes on c language is here check it out
The best every notes on c language is here check it outThe best every notes on c language is here check it out
The best every notes on c language is here check it out
 
Theory1&amp;2
Theory1&amp;2Theory1&amp;2
Theory1&amp;2
 
Cbasic
CbasicCbasic
Cbasic
 
Cbasic
CbasicCbasic
Cbasic
 
Best C++ Programming Homework Help
Best C++ Programming Homework HelpBest C++ Programming Homework Help
Best C++ Programming Homework Help
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
Pointers and Dynamic Memory Allocation
Pointers and Dynamic Memory AllocationPointers and Dynamic Memory Allocation
Pointers and Dynamic Memory Allocation
 
Token and operators
Token and operatorsToken and operators
Token and operators
 
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptx
 
dinoC_ppt.pptx
dinoC_ppt.pptxdinoC_ppt.pptx
dinoC_ppt.pptx
 
C language
C languageC language
C language
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
 
Cbasic
CbasicCbasic
Cbasic
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptx
 
Input output functions
Input output functionsInput output functions
Input output functions
 
C language basics
C language basicsC language basics
C language basics
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1
 
Embedded C - Lecture 2
Embedded C - Lecture 2Embedded C - Lecture 2
Embedded C - Lecture 2
 
Tut1
Tut1Tut1
Tut1
 

More from thirumalaikumar3

Control flow in c
Control flow in cControl flow in c
Control flow in c
thirumalaikumar3
 
C function
C functionC function
C function
thirumalaikumar3
 
Coper in C
Coper in CCoper in C
Coper in C
thirumalaikumar3
 
C basics
C   basicsC   basics
Structure c
Structure cStructure c
Structure c
thirumalaikumar3
 
String c
String cString c

More from thirumalaikumar3 (6)

Control flow in c
Control flow in cControl flow in c
Control flow in c
 
C function
C functionC function
C function
 
Coper in C
Coper in CCoper in C
Coper in C
 
C basics
C   basicsC   basics
C basics
 
Structure c
Structure cStructure c
Structure c
 
String c
String cString c
String c
 

Recently uploaded

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
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
 
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 Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
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
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
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
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
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
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
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)
 

Recently uploaded (20)

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
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
 
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 Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..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
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
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...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
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
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 

Data type2 c

  • 1. Lectures on Busy Bee Workshop 1 DATA TYPE IN CDATA TYPE IN C This session Outline Tokens Data Types Statements Types
  • 2. Lectures on Busy Bee Workshop 2 Tokens in CTokens in C 5 Tokens 1. Keywords 2. Identifiers 3. Constants/Literals 4. Operators 5. White Spaces/Other symbols Basic elements for building a program
  • 3. Lectures on Busy Bee Workshop 3 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/Literals Constants like 13, ‘a’, 1.3e-5, “Raj” etc. Integer constant Character constant String constant Float or Real constant
  • 4. Lectures on Busy Bee Workshop 4 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, keywords and constants.
  • 5. Lectures on Busy Bee Workshop 5 Tokens in C - ExampleTokens in C - Example void main() { int a=25; float b=45.0; char c='A'; float sum; sum=a+b+c; printf("Result =%fn",sum); } What will be the output? Tokens Keywords? Identifiers? Constants? Operators? Symbols?
  • 6. Lectures on Busy Bee Workshop 6 Basic Data TypesBasic Data Types Data types are used to indicate the nature and size of the data. Data Type Nature Size Range char Character constant 1 Byte – 8 bits -128 to 127 int Integer constant 2 Bytes – 16 bits -32768 to 32767 float Real constant 4 Bytes – 32 bits 3.4 * (10**-38) to 3.4 * (10**+38) double Real constant 8 Bytes – 64 bits 1.7 * (10**-308) to 1.7 * (10**+308) Type Modifiers - signed, unsigned, short, and long A type modifier alters the meaning of the base data type to yield a new type.
  • 7. Lectures on Busy Bee Workshop 7 Data TypesData Types Integral data types – Numbers without decimal point char / signed char Stored as 8 bits. Unsigned 0 to 255. unsigned char Signed -128 to 127. int /signed int Stored as 16 bits. Unsigned 0 to 65535. unsigned int Signed -32768 to 32767. short int Same as int. long / long int Stored as 32 bits. Unsigned 0 to 4294967295. signed long /signed long int Signed -2147483648 to 2147483647 unsigned long int All of the type modifiers can be applied to the base type int. signed and unsigned can also be applied to the base type char. Control String/Format Specifier – %c, %h, %d, %l, %u, %ul These are not valid constants: ? 25,000 7.1e 4 $200 2.3e-3.4 etc.
  • 8. Lectures on Busy Bee Workshop 8 Data TypesData Types Floating Point Numbers Floating point numbers are rational numbers. Always signed numbers. i.e Numbers with decimal point. float • Typically stored in 4 bytes(32 bits) • Range - 3.4 * (10**-38) to 3.4 * (10**+38) Double • Typically stored in 8 bytes(64 bits) • Range - 1.7 * (10**-308) to 1.7 * (10**+308). Long double • Typically stored in 10 bytes (80 bits) • Range - 3.4 * (10**-4932) to 1.1 * (10**+4932) Control String/Format Specifier – %f, %e, %lf
  • 9. Lectures on Busy Bee Workshop 9 Data TypesData Types 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”
  • 10. Lectures on Busy Bee Workshop 10 Data TypesData Types Character and String data types char /signed char/unsigned char • Typically stored in 1 byte(8 bits) • Range – signed -128 to 127, unsigned 0 to 255 char name[20] – Character Array • Above example occupy 20 bytes to store maximum of 20 characters of any one name. • char name[5][20] – Store any five name, each name have maximum of 20 letters each. Control String/Format Specifier – %c, %s
  • 11. Lectures on Busy Bee Workshop 11 Data Types - SummaryData Types - Summary Data Types Length Range unsigned char 8 bits 0 to 255 char 8 bits -128 to 127 unsigned int 16 bits 0 to 65,535 short int 16 bits -32,768 to 32,767 int 16 bits -32,768 to 32,767 enum 16 bits -32,768 to 32,767 unsigned long 32 bits 0 to 4,294,967,295 long 32 bits -2,147,483,648 to 2,147,483,647 float 32 bits 3.4 * (10**-38) to 3.4 * (10**+38) double 64 bits 1.7 * (10**-308) to 1.7 * (10**+308) long double 80 bits 3.4 * (10**-4932) to 1.1 * (10**+4932)
  • 12. Lectures on Busy Bee Workshop 12 enum & typedef Typeenum & typedef Type Enum Defines a set of constants of type int. Example: enum modes { LASTMODE = -1, BW40 = 0, C40, BW80, C80, MONO = 7 }; Here "modes" is the type tag. "LASTMODE", "BW40", "C40", etc. are the constant names. The value of C40 is 1 (BW40 + 1); BW80 = 2 (C40 + 1), etc. typedef Define a new data type using existing types Example : typedef int Number; typedef char String[20];
  • 13. Lectures on Busy Bee Workshop 13 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
  • 14. Lectures on Busy Bee Workshop 14 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;
  • 15. Lectures on Busy Bee Workshop 15 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 ); }
  • 16. Lectures on Busy Bee Workshop 16 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 ); }
  • 17. Statement TypesStatement Types Input Statements – scanf(), getchar(), gets() etc Output Statements – printf(), putchar(), puts() etc Declaration Statement – Datatype variablelist; Assignment Statements - variable=expression;/(=,+=,-+,*=,/=) Control statements – if, if …else, nested if, switch Iteration statements – for, while, do while Lectures on Busy Bee Workshop 17
  • 18. Try this in lab sessionTry this in lab session Program for print the memory allocation of all data types. Program for print your address label. Program for add this two number 1,20,000 and 80,500. Write a program to illustrate enum & typedef. Rewrite Program 2 for statements illustration (i.e Get any number <5, 1 time, or 2 time. Lectures on Busy Bee Workshop 18 1. Know the date type size 2. Flow control, tokens 3. Size limit, control string 4. enum & typedef 5. Statements