Important Program of C language in O level exam january 2019
STRUCTURE IN C
|
structure in c |
SYNTAX OF STRUCTURE
|
syntax of structure in c |
Remember structure defined in c with the help "struct" keyword as shown in above.
LOCAL DECLARATION OF STRUCTURE IN C
|
local declaration of structure in c |
Local declaration of structure means when structure declared within main() body/block as
shown in above .
GLOBAL DECLARATION OF STRUCTURE IN C
|
global declaration of structure in c |
Global declaration of structure means when structure declared outside the main() body/block as
shown in above .
MEMORY CONSUMED BY STRUCTURE
|
memory consumed by structure |
INITIALIZATION OF STRUCTURE VARIABLE
1ST at the time of declaration of variable
|
Initialization of structure variable in c |
2ND after declaration of variable
|
Initialization of structure variable in c |
COPY STRUCTURE DATA OF TWO VARIABLE
|
copy of structure data of two variable in c |
NOTE :--Here we can copy structure data type of one variable i.e today into another i.e d1 in two way, for example first way is that you can copy all data into at a time i.e d1=today; or you can copy one by one i.e d1.d=today.d; d1.m=today.m; d1.y=today.y; .One thing to remember for campus or interview point of view that struct is keyword that always used while declared any user defined variable in structure and when ever you used the variable which declared with help of struct keyword i.e today or d1 for initializing the value then used dot operator i.e today.d,today.m or d1.d,d1.m and so on... if this article is helpful then please like and share
and if you have any query then please comments
UNION IN C
|
union defination |
DIFFERENTIATE BETWEEN STRUCTURE AND UNION
|
Different between structure and union |
most important different between structure and union is that it's memory consumption in program i.e structure consume memory seperately i.e 2byte for int and 4byte for float and 1byte for char therefore total 5byte but The Union conducts only the largest bytes or data type in memory i.e in above example largest byte is float so it's used 4byte variable only and access all data type variable in 4byte at a time .
HOW TO ACCESS UNION ?
|
Access of union in c |
EXAMPLE OF UNION IN C
|
Example of union in c |
NOTE :-
Remember that in the quotation given above, we can only use the one value of the one variable at a time i.e int x=5 or float y=3.5 or char z=a as we seen in above example i.e we initialize one value and print it like x=5 and again initialize y=3.5 and print it and initialize again z='a' and print it and all variable memory will be float type that's why it's output will be shown on screen is --
OUTPUT -
X=5
Y=3.5
Z=a
Comments
Post a Comment