Important Program of C language in O level exam january 2019


Important Program of C language in O level exam january 2019

Merits and Demerit of Array


Merits:
(a) We can easily access each element of array.
(b) Not necessity to declare too many variables.
(c) Array elements are stored in continuous memory location.

Demerit:
(a) Wastage of memory space. We cannot change size of array at the run time. 
(b) It can store only similar type of data.  



Difference between Call by Value and Call by Reference


CALL BY REFERENCE




call by value,call by reference
call by reference


SYNTEX :--



call by value,call by reference
syntex of reference

Here in above Syntex we use actual and formal argument i.e fun(a,b) is actual and void fun(intx,inty) is formal argument. if you brief explanation then check my previous post of pointer.

EXAMPLE :--


call by value,call by reference
example of call by reference



OUTPUT :--

call by value,call by reference
output


Call By Value (Takes something and returns nothing)

type of function in c,example of function in c
example of function in c 



NOTE -As we know that variables declaration in a function can not be accessed in any other function, but we want that if the data in the variable created in the main function is accessed in the add function, then at the time when compiler call the add function we have to pass the variable in its parenthesis  i.e x,y as shown in above example ,  when the add function is created, then the variable has to be declarated in parentheses i.e int a,int b


type of function in c,function call in c
function call in c


type of function in c,function call in c
call by function



NOTE -- In previous lecture we have discuss the function defined and funtion calling ,now in above example we see how to declare a function . Remember that funtion declaration alway declared either in body of  main () or before main() as we see in above example .



call by value
call by reference
In call by value, a copy of actual arguments is passed to formal arguments of the called function and any change made to the formal arguments in the called function have no effect on the values of actual arguments in the calling function.
In call by reference, the location (address) of actual arguments is passed to formal arguments of the called function. This means by accessing the addresses of actual arguments we can alter them within from the called function.
In call by value, actual arguments will remain safe, they cannot be modified accidentally.
In call by reference, alteration to actual arguments is possible within from called function; therefore the code must handle arguments carefully else you get unexpected results.


If this article is helpful to you then please like and share. Thank you..


Comments

Popular posts from this blog

Notepad, Wordpad and Paint

O LEVEL- INTERNET TECHNOLOGY & WEB DESIGN

O LEVEL- INTERNET TECHNOLOGY & WEB DESIGN