Hello and welcome. So today in today's lecture we'll understand in C programming output based
question on structure. So prior to this we have discussed everything about structure
structure, union and then difference between structure and union and then area of a structure
and then last nested structure. Now today we'll discuss some output based question which is
generally asked in competitive examination what what will be the output of this structure. So
let's see let's see. So have you ever wondered such type of questions. So let's start this
question. So you have given a you have created a structure TCS and then you have created four
variable X Y Z and W fine and you have created a variable A. I always told you the moment you
create a variable the variable will be created something like that and there will be four part
A is a variable name and there will be four part one is X one is Y one is Z and one is W fine
Now what am I initializing this X with one. No I'm not initializing because you cannot initialize
I've already taught you that you cannot initialize actually you cannot initialize. You can only
initialize once the variable is created. So I'm not initializing. So what is the use of this colon
So let me explain you very important that in what. Now let me let us check about output. So
in function mean you are printing size of a size of a. So what is the size of a structure which
takes the size of all the all the variable size. So integer let's suppose integer takes four by
It is given that integer takes four by. So structure will take the size of all the members
of 4 4 4 4. So what will be the answer. According to you 16. So if you are thinking 16 is the answer
So I must say 16 is not the answer. 16 is not the answer. Then what is the answer. If 16 is not
the answer then what is the answer. So this colon represent the bit value. So I'm asking compiler
out of four byte only give me one bit one bit. So what is byte one byte is equal to eight bit
So I integer take four bytes out of four byte. I'm asking compiler to give me only one bit
Fine. This is bit eight bit fine. OK then. So this is one bit. This is two bit. This is four bit
And this is eight bit. So one plus two is three three plus four is seven and seven plus eight is
what 15 15. It is 15. So answer is 15. What 15 15 bit. So answer is 15. No answer is not 50
All the answer are in bytes. All the answer is are in byte. So 15 bit. So what 15 bit represent
So 15 bit comes under what one memory block which is four byte four byte means 32 bit. So in order
to know in order to allocate memory for this structure I need only 15 bit and 15 bit can be
accommodated in maximum how many byte. So because one byte block take four byte. So minimum size is
four byte. So in four byte that is 32 bit. Can you can you allocate this 15 bit. Yes absolutely
So answer is what four byte. So let's check the answer. Yes exactly. The answer is four byte
Exactly correct. So answer is four byte. Fine. Now let's move to the different question
Now I've changed. This is the second question. Now if I've changed this now what will be the output
If I've changed this what will be the output. Here you have now total and proper understanding
of bits. Now X is taking one bit. X is taking one bit. Fine. X is taking one bit. This is taking 10
bit 11 bit. 11 and 14 is what 25 bit and 25 and 8 is what 33. 33 bit. Now can I store this 33 bit
in four byte. What is four byte. What is four byte. Four byte is 32 bit. So can you insert this 33 in
32. No. So in that case I need one more block and the minimum size of block is four byte. So again
I need this four byte. Fine. So in order to store this 33 bit I need at least two blocks and this
two block will add into eight eight byte. So answer correct answer will be eight byte. So this is the
correct answer. Hope you understood what I have what I was trying to tell you. So the answer will
be the size of A. The size of A will be size of A will be eight byte. Fine. If the size of integer
variable is four byte then it will take eight byte. Fine. Now at last I'll say what. Thank you so much
for watching. Please like subscribe and share. Thank you. Thank you so much. Thank you very much