Chapter 13 Datatypes Variables
Chapter 13 Datatypes Variables
SURESH TECHS
CHAPTER 13 C PROGRAMMING COURSE
NOTE
ఈ చాప్ట ర్ లో కకుంచ ుం ఎకకువ discuss చేస్ా తన . కతబట్టట, మొదట్ట
స్తరి అన్నీ అర్ధుం అయ్యే అవకతశుం లేద .
నా బంగారు పుట్టలో
వేలు పెడితే కుట్టనా
7 చేప్ల కథ
Sometimes we will stop!
నా బంగారు పుట్ట లో
వేలు పెడితే కుట్ట నా
pot-a pot-b
pot-a = 10
pot-b = 30
Variable
• It is used to store data
• It’s value can be changed at any
time
a b
కొన్నన రోజులు (Research)
Father
3. Fight with king “SURBALI”
Dennis Ritchie
New laptop
Compiler
printfprograms.exe printfprograms.c HARD DISK (500gb,1tb,2tb)
/printfprograms.out
• You have S, U characters and you have to come up with different
combinations with size(length) of 2
• SU
• US
Small test
• UU
• SS
• A bit is a binary(0 or 1) digit.
• A bit can hold only one of two values: 0 or 1
• A bit (short
Bit?for binary digit) is the smallest unit of data in a
computer
• 00
• 01
• 10 Combinations(0 & 1 – size of 2 bits)
• 11
• 000
•
2^3 = 8 2^2 = 4
00
• 001 • 01
•
• 010 10
Combinations(0 & 1 – size of 3 bits)
• 11
• 100
• 101 8 bits(01001101) - 1 byte
• 110
• 011 2^8 = 2*2*2*2*2*2*2*2 = 256
• 111 With 1 byte, we can represent 256 numbers
data type defines More the memory,
size of the data more the size😍😍
int a = 10;
• 4 bytes –Memory
32 bits • 2^32= 4,29,49,67,296
60 00110100011010001
• Data type defines type of data and size of data
• Size is nothing but memory – how much data that variable can hold
What is data type?
Basic data types(most used)
https://opensource.apple.com/source/xnu/xnu-792.13.8/EXTERNAL_HEADERS/ppc/limits.h.auto.html
https://opensource.apple.com/source/Libm/Libm-47.1/i386.subproj/float.h.auto.html
• Used to represent whole numbers that can have zero, positive and
negative values but no decimal values
• We use int for declaring a integer variable
• int a;
int
• We can declare multiple variables at once
• int a,b,c;
• Used to represent numbers with decimal points
• Used when more precision is required
float, double
Difference between Float and Double
Float Double
4 bytes – 32 bits 8 bytes – 64 bits
Used to represent decimal values( ex: 7.987) Used to represent decimal values( ex: 8.182)
Single precision data type(6 decimal places) Double precision data type(15 decimal places)
Ex: 7.879888 Ex: 8.182191283871221
It is faster It is slow as it works with very large values
• sizeof(data type)
• sizeof(variable)
Size of data type
• int noOfBores = 10;
• float passPercentage = 30.26;
• What about SURBALI 🤣🤣?
SURBALI
How do we represent a Collection of characters is
character? called a string
• It is used to store single character values
• C uses achar
character encoding
data type scheme called ASCII to represent
characters or special characters
[
[ humans[]
• char – to represent one character.
• yes – collection of y, e, s
• String isStrings
a sequence of characters
terminated(end) with a null
character \0
• Ex: char yes[]=“yes” y e s \0
• char name[10]=“suresh”;
String literal //we have assigned 10 bytes of memory
• char name[]={‘s’,’u’,’r’,’e’,’s’,’h’,’\0’}; //declaring using char array
data types
After introducing modifiers:
long
• int - affects the range of values(long, short)
short
• signed int
• unsigned int
• long int
• short int
• int –(32 bit environment) - 4 bytes – 32 bits
• Range: 2^32 => 4,29,49,67,296
• Signed: (positive and negative)=>
Signed and unsigned – int -2,147,483,647 to 2,147,483,647
• Unsigned: (only positive)=> 0 to 4,29,49,67,296
Default is signed
All basic data types with modifiers
19 decimal places
• You have to store half glass of water in one of the containers and you
can’t use the container for another purpose
Compiler
printfprograms.exe printfprograms.c HARD DISK (500gb,1tb,2tb)
/printfprograms.out
int a;
type = int
• It is used to store data size = 2 or 4 bytes
• It’s value can be changed at Range = -2,14,74,83,648 to 2,14,74,83,647
any time
Rules to define
Variable - variables
actual
definition
• Every variable in c has a
specific type, which
determines the size of the
memory and the range of
values that can be stored
within that memory.
• Who is the father of C Language?
• Dennis Ritchie
• dennis Ritchie
Case sensitive
• Dennis ritchie
• Variables in C can have not only data type but also storage class that
provides information about their location and visibility
User Derived
Defined Data types
Structure
Array
Union String
Typedef Pointer
Enum Functions