Types of Function calls in C
Program เคฎें เคเคฌ เคญी เคเคช function เคो use เคเคฐเคจा เคाเคนเคคे เคนै เคคो เคเคธे call เคเคฐเคคे เคนै।
argument-list – arguments เคตो real values เคนोเคคी เคนै เคो เคเคช functions เคो call เคเคฐเคคे เคธเคฎเคฏ เคชाเคธ เคเคฐเคคे เคนै। เคฏे values function definition เคฎें parameters เคो assign เคนोเคคी เคนै। เคเคธเคे เคฌाเคฆ เคเคจ values เคชเคฐ processing เคนोเคคी เคนै เคเคฐ result return เคिเคฏा เคाเคคा เคนै।
Addition เคे function เคो call เคเคฐเคคे เคธเคฎเคฏ เคोเค 5 values เคชाเคธ เคเคฐेंเคे เคैเคธे เคी 5 เคเคฐ 7, เคเคจเคी เคเคเคน variables เคญी pass เคिเคฏे เคा เคธเคเคคे เคนै เคिเคจเคฎें values store เคी เคเคฏी เคนै।
เคฏे values parameter variables a เคเคฐ b เคो assign เคนो เคाเคँเคी เคเคฐ function เคे เค ंเคฆเคฐ เคเคจ variables เคชเคฐ เคนी processing เคนोเคคी เคนै। เคเคธे functions เคिเคจเคฎें parameters defined เคिเคฏे เคเค เคนै เคเคฐ เคฏเคฆि เคเคช function call เคเคฐเคคे เคธเคฎเคฏ arguments เคชाเคธ เคจเคนीं เคเคฐเคคे เคนै เคคो program เคฎें error เคเคคी เคนै।
Addition เคे function เคो เคเคช เคเคธ เคช्เคฐเคाเคฐ call เคเคฐ เคธเคเคคे เคนै।
C language เคฎें functions เคो 2 เคช्เคฐเคाเคฐ เคธे call เคिเคฏा เคा เคธเคเคคा เคนै।
- Call by Value – เคเคธ เคคเคฐीเคे เคฎें argument เคे เคฐूเคช เคฎें values เคเคฐ variables เคชाเคธ เคिเคฏे เคाเคคे เคนै।
- Call by Reference – เคเคธ เคคเคฐीเคे เคฎें argument เคे เคฐूเคช เคฎें variables เคा reference เคชाเคธ เคिเคฏा เคाเคคा เคนै।
Call by Value
เคเคฌ เคเคช function call เคเคฐเคคे เคธเคฎเคฏ argument เคे เคฐूเคช เคฎें เคोเค value เคชाเคธ เคเคฐเคคे เคนै เคคो เคตเคน parameter variables เคฎें copy เคนो เคाเคคी เคนै เคเคฐ เคเคธเคे เคฌाเคฆ เคเคจ variables เคชเคฐ operations perform เคिเคฏे เคाเคคे เคนै।
เคเคธी เคช्เคฐเคाเคฐ เคเคฌ เคเคช function เคो call เคเคฐเคคे เคธเคฎเคฏ เคोเค variable เคชाเคธ เคเคฐเคคे เคนै เคคो เค เคธเคฒ เคฎें เคตเคน variable function เคฎें เคจเคนीं pass เคिเคฏा เคाเคคा เคนै เคฌเคฒ्เคि เคเคธ variable เคी value parameter variable เคฎें copy เคी เคाเคคी เคนै เคเคฐ เคเคธเคे เคฌाเคฆ เคเคธ parameter variable เคชเคฐ operations perform เคिเคฏे เคाเคคे เคนै।
เคฏเคฆि เคเคชเคฐ เคฆिเค เคเค addition เคे function เคो call เคเคฐเคคे เคธเคฎเคฏ เคฆो integer variables x เคเคฐ y pass เคिเคฏे เคाเคँ เคคो เคเคธा เคเคฐเคจे เคชเคฐ เคเคจ เคฆोเคจों variables เคी value parameter variables a เคเคฐ b เคฎें copy เคนो เคाเคฏेเคी เคเคฐ เคเคจ เคชเคฐ addition perform เคเคฐเคे result return เคिเคฏा เคाเคเคा।
เคเคธ เคคเคฐเคน เคे function call เคो call by value เคเคนा เคाเคคा เคนै। เคเคธเคฎें เค เคธเคฒ argument variables เคी value change เคจเคนीं เคนोเคคी เคนै เคเคฐ เคो เคญी operation เคนोเคคा เคนै เคตเคน parameter variables เคชเคฐ เคนी perform เคนोเคคा เคนै।
output
value of x in calc function is 20
value of x in main is 10
Call by Reference
เคिเคธी function เคो call เคเคฐเคคे เคธเคฎเคฏ เค เคธเคฒ variables pass เคเคฐเคจे เคी เคฌเคाเคฏ เคเคจเคा address เคญी เคชाเคธ เคिเคฏा เคा เคธเคเคคा เคนै। เคเคธा เคเคฐเคจे เคชเคฐ เคเคจ variables เคा address parameter variables เคฎें copy เคนोเคा เคเคฐ parameter variable memory เคฎें เค เคธเคฒ argument variables เคो เคนी point เคเคฐेंเคे।
เคเคธ เคคเคฐเคน เคे function call เคो call by reference เคเคนा เคाเคคा เคนै। เคเคธ เคคเคฐเคน เคे function call เคฎें เค เคธเคฒ argument variables เคा address pass เคिเคฏा เคाเคคा เคนै। เคเคธा เคเคฐเคจे เคธे function เคे เค ंเคฆเคฐ เคฏเคฆि parameter variables เคी values เคฎें changes เคเคคे เคนै เคคो เคเคธเคธे เค เคธเคฒ argument variables เคी values เคฎें เคญी changes เคเคคे เคนै। เคฏाเคจी parameters เคฎें change เคเคจे เคชเคฐ arguments เคญी change เคนो เคाเคคे เคนै।
เคเคธ เคคเคฐเคน เคे function call เคฎें arguments เคो address of operator (&) เคे เคธाเคฅ pass เคिเคฏा เคाเคคा เคนै। เคฏเคน operator argument เคा address parameter variables เคो pass เคเคฐเคคा เคนै। เคเคธเคे เค เคฒाเคตा function เคे declaration เคเคฐ definition เคฎें parameters เคो value at (*) operator เคे เคธाเคฅ define เคिเคฏा เคाเคคा เคนै।
output
value of x is 20
0 Comments
Please don't Add spam links,
if you want backlinks from my blog contact me on rakeshmgs.in@gmail.com