Important Program of C language in O level exam january 2019



Important Program of C language in O level exam january 2019

STRUCTURE  IN C



structure program in c,structure in c
structure in c

SYNTAX OF STRUCTURE

structure program in c,structure in c
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


structure program in c,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


structure program in c,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



structure program in c,structure in c
memory consumed by structure 

INITIALIZATION OF STRUCTURE VARIABLE


1ST at the time of declaration of variable

structure program in c,structure in c
Initialization of structure variable in c

 2ND after declaration of variable


Initialization of structure variable in c



COPY STRUCTURE DATA OF TWO VARIABLE

structure program in c,structure in c
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 in  c , different between structure and union
union defination



DIFFERENTIATE BETWEEN STRUCTURE AND UNION 



union in  c , different between structure and union,union in c
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 ?


union in  c , different between structure and union
Access of union in c

EXAMPLE OF UNION IN C

union in  c , different between structure and union
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

Popular posts from this blog

Notepad, Wordpad and Paint

O LEVEL- INTERNET TECHNOLOGY & WEB DESIGN

O LEVEL- INTERNET TECHNOLOGY & WEB DESIGN