https://www.rakeshmgs.in/search/label/Template
https://www.rakeshmgs.in


๐ŸŒž เค†เคช เคธเคญी เคตिเคœिเคŸเคฐ्เคธ เค•ो เค›เค  เคฎเคนाเคชเคฐ्เคต เค•ी เคนाเคฐ्เคฆिเค• เคถुเคญเค•ाเคฎเคจाเคं ๐Ÿ™๐ŸŒผ

RakeshMgs

Types of Functions Call in C Programming Hindi Notes

Updated:

Types of Function calls in C

Program เคฎें เคœเคฌ เคญी เค†เคช function เค•ो use เค•เคฐเคจा เคšाเคนเคคे เคนै เคคो เค‰เคธे call เค•เคฐเคคे เคนै।

    
    
functionName(argument1, argument2,...);

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 เค•เคฐ เคธเค•เคคे เคนै।

    
    
/* Calling add function with arguments 5 and 7*/ add(5,7);

C language เคฎें functions เค•ो 2 เคช्เคฐเค•ाเคฐ เคธे call เค•िเคฏा เคœा เคธเค•เคคा เคนै।

  1. Call by Value – เค‡เคธ เคคเคฐीเค•े เคฎें argument เค•े เคฐूเคช เคฎें values เค”เคฐ variables เคชाเคธ เค•िเคฏे เคœाเคคे เคนै।
  2. 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 เคนोเคคा เคนै।

    
#include <stdio.h> void calc(int x);// function declaration int main() { int x=10; calc(x); // this will print the value of 'x' return 0; } void calc(int x)// function definition { // chnaging the value of 'x' x = x + 10; printf("value of x in calc function is %d", x); }

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 เค•िเคฏा เคœाเคคा เคนै।

    
#include <stdio.h> // function taking pointer as argument void calc(int *p); int main() { int x=10; // passing address of 'x' as argument calc(&x); printf("value of x is %d", x); return 0; } void calc(int *p) //receiving the address in a reference pointer variable { /* changing the value directly that is stored at the address passed */ *p = *p + 10; }

output

value of x is 20


เค†เคชเค•ो เค†เคฐ्เคŸिเค•เคฒ เค•ैเคธा เคฒเค—ा? เค…เคชเคจी เคฐाเคฏ เค…เคตเคถ्เคฏ เคฆें
Please don't Add spam links,
if you want backlinks from my blog contact me on rakeshmgs.in@gmail.com