data type c data type | data type c - user defined data types in c

<image>

this is shinhwa's in the last session so
we discussed the basic concepts of a
data types into the first discussion
about the first data type integer data
type divides into six classifications so
now the first classification is a
shorter type short again divided into
two sub classifications right so already
we discussed here it is signed data type

and second one is a unsigned data type
short is a data type user to store an
integer value right and here it is
divided into two types signed and
unsigned so what is a signed data type
and what is the unsigned data type means
using signed we can store only a

What is main data type of a function in C?

positive value but using signed data
type a positive value and negative value
also we can store using unsigned
we can store only positive value right
and what is the size of short either it
is a signed short or it is unsigned
short it occupies two bytes memory how
many bytes it occupies two bytes memory

so using two bytes memory so what is the
minimum value we can store and what is
the maximum value we can store just look
at the memory allocation process here
suppose two bytes memory I am taking
this is the first byte this is the first
byte I'm taking first byte and this is

What are the main data types?

the second byte is the second byte
so using two bytes memory what is the
minimum value we can store right so the
data will be stored in the form of
binary values so if you place all our
zeros all our zeros the minimum value is
a zero and the maximum value what is the
maximum value we can store using two

bytes memory using two bytes memory is
we need to place all ones all our ones
this is the value is a 65535 65535 so
using two bytes memory a minimum value a
minimum integer value we can store is a
zero and the maximum integer value we
can store is a 65535 right so here it is

a simply how can we understand means is
it two bytes means one byte is equals to
8-bit one byte is equals to 8 bits so
two bytes is nothing but a 16-bit so we
have to calculate to power 16 value to

What is default data type in C?

power 16 value is a 65,536 but here it
is a storing value starts with a 0 so
here it is a 0 to 65535 65535 so what is
that unsigned datatype and what is the
sign data type means unsigned always

stores a positive value so the range of
unsigned datatype is 0 to 65,535 here it
is 2 bytes so we need to find out the
value to power 16 the value is a 6 5 5
35 sorry six-five 536 and here it is a
range 0 to 65,535

this is a minimum value we can store and
this is a maximum value we can store and
next one come to this point here it is
using two bytes using two bytes signed
data type now what is the minimum value
and what is the maximum value here it is
65,536 by two just divide the value six
five five thirty six by two if you

divide so what is the value this is
three two seven six eight and here it is
three two seven six eight this is half
half of six five five thirty six so
negative values always starts with a - 1
- 2 - 3 and so on - 3 - 7 6 8 is ok so
negative values up to - 3 - 7 6 8 but

here it is a positive values starts with
a 0 1 2 and so on up to three two seven
six seven only sir why because we have
to include 0 also right 0 + 3 - 7 6 7 so
total 3 - 7 6 8 values so range - 3 - 7
6 8 2 + 3 - 7 6 7 + 3 - 7 6 7 so these
are the limits of short data type either
signed a data type or unsigned data type
using signed data type so what is the
minimum value we can store is a - 3 - 7

6 8 and what is the maximum value we can
store is a 3 - 7 6 7 and here it is
using unsigned short the minimum value
we can store is a 0 and the maximum
value we can store is a 65535 so these
are the limits of short data type and

What is main data type of function?

next important discussion is in how many
ways we can declare the short data type
and the format specifiers of a short
data type so what are this see now I
just want to declare

signed data type variable in my program
signed a data type variable in my
program how here suppose these are
signed declarations signed declarations
and followed by unsigned declarations
also we'll see C in the Declaration of
variable if you do not specify whether
the variable is assigned variable or
unsigned variable by default that is

signed variable by default that is sign
that means the variable accepts both a
positive value and a negative value that
is called signed here it is simply you
can declare like this variable short a
this is declaration of variable variable
a is of type a short type right here it
is suppose if you want to write integer
also we can add short integer a these
two of type short type only sir where is
the signed or unsigned I am NOT

specifying so by default these two
variables are signed variables only so
here it is sir can I write explicitly
yes you can

data type c

signed short a it is allowed and signed
complete declaration last one signed
short integer a in these many ways we
can declare a signed variable in to your
C program sir unsigned declarations here
it is unsigned declarations we must
specify explicitly these are unsigned
declarations only two ways first one is

a unsigned short a and next one unsigned
short integer a so these are so total
six declarations about a short data type
first four comes under signed short
declarations and the second
means what a remaining two declarations
comes under unsigned declarations right

in these many ways we can declare and
the next important thing is format
specifier we can also call it as a
format string in a C language so what is
the format specifier and what is its
importance right if you want to read the
information or if you want to display
the information formatting is very very

important right in which format you have
to read the information in which format
you have to print the information that
you have to specify to the computer so

data type

this is called a formatting specifier so
that is why the name format specifier
simply for all the signed declarations
all the four signed declarations the
format specifier is percentage D these
are called format specifiers format
specifiers and next one for these two

for unsigned declarations format
specifier is a person is you percent is
you these four signed declarations we
are processing with the help of the
specifier is percentage D and remaining
two declarations unsigned declarations
we are specifying with a person days you
these are signed and unsigned
declarations of short type and here it
is format specifiers we are using so
based on these so we will see write the
programming on short data type so now we

will see so some of the examples on a
short data type write C for example I
just want to print a small value on the
console here it is we are writing the
program execution starts from the main
method execution starts from the main
method and here it is I am declaring one
variable variable is a short variable
short a equals to some value 10 we are
store

What is main data type in C?

shot a equals 210 and next if you want
to clear the screen
CLR SCR clear screen remember clear
screen always we need to write after
declaration of all the local variables
already we discussed in the local
variables concept all the local

variables of a block you must place in
the beginning statements
so after declaration of all the
variables only you have to clear the
screen next clear screen function is
available in a library is a header file
Co ni WA dot H so I am including that
and next I want to print so what is the
function printf function inside the

double quotes we have to write that
format specifier what format specifier
short format specifier by default it is
assigned if you do not mention whether a
variable is a signed variable or

user defined data types in c

unsigned variable by default it is a
signed variable so format specifier is
assigned format specifier and here we
are writing the variable that what you
want to print a is a variable we just

want to print so the value variable
value it will print here in this place
in this place so to this program the
output is write 10 on the console it
will print the value 10 okay so this is
a simple program here format specifier
is very very important with the help of
format specifiers only we are reading

the elements and we are printing the
elements here simply I am declaring one
short variable write variable we name is
a a with the value 10 so 10 it will
print next we will see write some
complex programs okay see so first of
all I am writing

right the limits of a signed data type I
mean signed short data type in the form
of circle observed because based on that
circle only now we are writing this
program observed here it is this is a
signed short circle limits error minus
three two seven six eight two plus three

two seven six seven plus three two seven
six seven these limits I am writing in
the form of circle observed in the form
of circle we are writing this is science
short circle signed short that is
nothing but a percent is d any value you
want to count either positive value or
negative value starts with a zero

counting always starts with a zero
positive values counting in a clockwise
direction so like that and the value
maximum value is a three two seven six
seven positive values counting in a
clockwise direction remember negative
values counting in anti-clockwise

direction - two - three - four and so on
up to - three - seven six eight
somewhere I am writing minus 3 - 7 6 7 -
3 - 7 double 6 and so on so these are
negative values in a counterclockwise
direction or anti-clockwise direction
just limits of a short data type I have
written right in the form of circle now
based on this now we will see some

programs on a short data type observe
here clearly hash include header files I
am including stdio dot H and one more
header file Co ni WA dot H for clear
screen purpose Co n I would not H inside
that main inside the main
and here it is we are declaring one
short variable short x equals to some

three to seven six nine we are storing
three two seven six nine and here clear
screen clear screen and we are printing
the message printf % is d that x value
we are printing observe here clearly the
statements execute one by one from top

to bottom from top to bottom it will
execute and here it is execution starts
from the main function the first
statement execution here it is X gets
memory allocation at any location X get
memory allocation X get memory
allocation but what is the value you are
storing 3 to 7 6 9 is the value you are
storing what is the value 3 to 7 6 9 you

are storing so based on this it will
count 3 to 7 6 9 is a positive value now
so it starts counting positive values
here 1 2 3 4 5 6 like that it will keep
on counting three two seven six seven
three two seven six eight three two

seven six nine so three two seven six
nine value is equals to minus three two
seven six seven it will not give any

error message it will store one garbage
value in the memory so what is the value
- 3 - 7 6 7 what is the value - 3 - 7 6
7 will go on store in the memory garbage
value next it will clear the screen next
we are printing so whenever we are
printing X value it has to collect so
from this it will collect the text value

what is that x value - 3 - 7 6 7 is a X
value it will fetch that value from
where from the memory
it will not look at the declaration area
declaration statement already completed
throughout no use next we are at the
third statement we are printing the x

value we are printing the x value so
what we are printing minus three two
seven six seven we are collecting but it
will not print directly what it will do
according to the format specifier what
format space where you have given
percent is d you have given so

percentage D circle it will check so
where is the percentage D circle here it
is this is percentage D circle in this
circle the value is present or not it
will check what is the value minus three
two seven six seven value is present or
not it will check in this circle yes -
three two seven six seven is there so it

will print the value output is a minus
three two seven six seven so here we are
violating the rules na right will it
give any error messages no error
messages it will store one garbage value
into the memory remember right that we
should understand because we are doing
the mistake so we should analyze clear
right we will see one more program see

here it is a just like a this program so
we will see some more complex programs
okay see suppose now I am changing that
x value x value to minus four x value to
minus four but here it is explicitly I
am specifying very clearly that this is
unsigned short integer

unsigned short integer value X value but
I am initializing with the value 4 so
actually unsigned will take only
positive values now yes but here it is
whenever we are trying to assign the
negative value according to that circle
so what is that circle now we have to
discuss about an unsigned circle also so
unsigned circle we are writing first the

value is a 0 to 65,535 this is unsigned
range we discussed already 0 to 65,535 I
am just writing in the form of circle
same values form of circle this is
percentage you is unsigned circle and
here it is a counting starts with a 0
only positive values are there 3 4 and
so on and so on what is the maximum
value is a 65535 and some more values 6
double 5 3 4 6 double 5 double 3 6

double 5 3 2 values we are writing so
this is a range just this we are writing
that range in the circle same story
negative values counting in

anti-clockwise Direction positive values
counting in a clockwise direction 1 is a
clockwise direction and second one is a
counterclockwise direction right
positive values counting and negative
values counting so here now I am trying
to store the value minus 4 so as usual
first X gets memory allocation X get

memory allocation x value is a minus 4
right first X memory will be allocated X
memory will be allocated but it has to
store the minus 4 value but what we have
given unsigned you have given so in
which circle it will check in this
circle or in this circle this is a
signed circle and this is unsigned
circle so in this circle it will check

in this circle it will check so here it
is we need to count that minus 4 value
minus 4 is a negative value so minus 1
- 2 - 3 - 4 - 4 value is equals to 6
double 5 3 2 so in the memory so what
value will go on store is a 6 double 5 3
2 will go on store 6 double 5 3 2 will
go on store and now here so we are
printing percentage you what is the

format specifier I have given percent is
you I have given percent is you so first
it will fetch that x value so what is
that x value please do not look at that
first statement in this program because
first statement is used to allocate the
memory only once you allocate the memory
from the second statement wherever you
use that variable always it will collect

the information from the memory only the
best example things generally for
example right i just deposit some amount
8000 rupees into my account today
right I visit the bank and I have to
write one received right for payment and

bank management first we'll follow that
received to perform the transaction by
just look at that received so they will
deposit 8,000 rupees into my account the
next day I just want to withdraw 5,000

rupees bank management will follow
received or my amount in the memory the
concept is later on so they will collect
that information from the memory they
will not maintain the receives in the
same way so once you declare the
variable once you declare the variable

in the first statement which is used to
allocate the memory only once memory
allocation has been completed from the
second statement it will follow the
memory only so whenever you are printing
X value it will fetch the text value 6
double 5 3 2 it will fetch so it will

collect that 6 double 5 3 2 and directly
it will not print again it will check
what format specifier you have given
what is

the format specifier % is you you have
given so percent is you means what in
this circle it will check percentage you
circle in this circle six double five
three two is present or not right
suppose if it is a present right so then
it will print that value s is there six

double five three two is present so in
the output in the output it will print
that message six double five three two
six double five three two it will print
remember okay and see for example one

more thing will see this is unsigned
value only but I am printing six double
five 3/8 we are storing now the value is
six five five thirty eight and we are
printing percent is u X and one more we
are printing printf percent is d X

percent is DX we are printing now
observe the concept what value will go
and store into the memory is first in
the memory what value will go on store
so you have given unsigned and the value
is a six double 5 3 8 so in which circle
it will check in the second circle it

will check in the percentage you Circle
it will check so it will start counting
0 1 2 3 4 and keep on counting 6 double
5 double 3 6 double 5 3 4 6 double 5 3 5
6 double 5 3 6 6 double 5 3 7 6 double 5
3 8 so 6 double 5 3 8 value is equals to

2 is equals to 2 so here it is in the
memory the value 2 will go and store
right it will not store 6 double 5 3 8
right so while counting in that circle
the value 6 double 5 3 8 is equals to 2
right so in the membrane out 2 is there
so far

statement completed next is control come
to that second statement clear screen
and next that control come to that third
statement we are printing X value what
is the x value to it we'll collect that
value to and here it is what format
specifier you have given percent is you

you have given what is the format
specifier percent is you you have given
right so percentage you circle it will
check in this circle the value two is

present or not yes the value 2 is
present value two is present so directly
it will print the value two output is it
to here next to the control come to that
fourth statement again it will fetch
that x value from the memory here it is
it will collect that x value from the
memory that is two and next format

specified it will check what is the
format specifier now percent is d is a
format specifier so we need to check in
the signed circle this is a percentage D
circle in this circle two is present or
not yes of course here it is in this
circle also two is present in this
circle also 2 is present so here also it
will print the value 2 it will print the

value 2 that's it ok so we will see one
last example just look at this see that
example suppose here I am writing some
worst things this is 3 to 7 double 6 and
this is 3 to 7 6 5 and this is three to

seven six four three two seven six four
now here unsigned I am declaring the
value - 3 - 7 7 2 this is the value I am
storing 3 - 7 7 2 is the value I am

trying to assigning to variable X but X
is of type word unsigned remember and
here it is we are printing that value
printf % is d x value we are printing
and once again we are printing that
you but I want to change the format

specifier that is percentage you x value
we are printing two times first time we
are giving that percentage D and second
time we are printing the percentage you
but Sir what value will go on stored
into X first X get memory allocation at

some location what value will go and
store unsigned unsigned value - three -
double seven - so in an unsigned circle
- three - double seven - you have to
counter - three - double seven - is a -
one - two - three - four like that -

three - double seven - you have to
counter it is a headache now
that is why compare these two just
compare these two circles almost same

but this is completely positive just
this is divided into positive and
negative but exactly how many numbers in
both the circles are same so while
counting so this counting and

discounting almost same - 1 - 2 - 3 - 4
and so on keep on counting - 3 - 7 6 8 -
3 - 7 6 9 - 3 - 7 7 0 - 3 - 7 7 1 and
this is minus 3 - 7 7 2 - 3 - 7 7 2 is
equals to 3 - 7 6 4 here it is somewhere
3 - 7 6 4 will be present in this circle
also both circles almost same so here it
is - 3 - double 7 2 in place of that

what value will go on store 3 - 7 6 4
will go on store 3 - 7 6 4 will go on
store now we are printing the text value
so as usual it will collect that x value
this is output it will collect that x

value what is that x value 3 - 7 6 4 not
3 - double 7 2 what is the value 3 - 7 6
4 it will collected after collecting 3 -
7 6 4 what format specifier you have
given is also important what is the 4
space fire % SD percentage D means what
this is the circle in this circle three
two seven six four is present or not yes
three two seven six four is present so
it will print the three two seven six

four only three two seven six four next
again X collecting what is it x value
three two seven six four but what format
specifier you have given percentage you
is a format specifier see here percent
is you is a format specifier in this

format specifier three two seven six
four is present or not yes once again
here it is there so it will print the
value once again three two seven six
four it is printing so any relation
between input and output no relation we
are storing - three - double seven - and
we are printing x value x value one time

we have given percentage D and one time
we have given percentage you but know
where we are getting that output is a -
three - double seven - so computer
processing is a completely different
depends on the what values we are
storing C language will not provide any
compile time errors if you are violating

the rules instead of giving error
messages right it is producing some
unexpected results but remember right in
an interview point of view they will ask

such type of questions only simple
questions they will never ask whether
you are perfect in a data types are not
they will ask the questions such type of
questions very complex questions they

will ask okay so this is the completely
about a short data type remaining data
types we will see in the next session so
thank you 


Post a Comment

0 Comments