JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Categories: C Language in hindi

User Define Function : Calls or Declaration in hindi यूजर डिफाइन फंक्शन कॉल या डिक्लेरेशन हिंदी में

यूजर डिफाइन फंक्शन कॉल या डिक्लेरेशन हिंदी में User Define Function : Calls or Declaration in hindi in c language :-
इससे पहले के article मे , हमने function difination को स्टडी किया | इस article मे ,function calling और declaration को स्टडी करगे |

Function Call:

किसी function को उसके नाम से easily call कर सकते है |function का parameter की लिस्ट जिसे actual parameter कहते है |इसका syntax होता है |
Function Name (Actual parameter);
जब function call satement execute होता तब कोम्प्लिएर का control उस function के defination पर  चला जाता है |यह पर function defination मे स्थित statement को line by line execute करता है और return statement से ओउपुत को main function मे return कर देता है |
उदाहरण के लिए :
#include<conio.h>
#include<stdio.h>
int add (int ,int )
void main()
{
int a,b ;
printf(“Enter your data”);
scanf(“%d $%d”,&a,&b);
c=add ( a ,  b );
printf(“Sum is %d”,c);
getch();
}
int add(int e,int f)
{
int sum;
sum=e+f;
return sum;
}
इसमें add एक function  है जिसमे actual parameter a और b की value , function defination satement मे formal value e और f मे pass होगी |
आउटपुट होगा :
Enter your data 12 23
Sum is 35
अलग अलग function call statement निम्न है :-
c=add(12,23);
c=add(12,b);
c=add(a,23);
c=add(a+1,12);
c=add(12,add(a,b));
पहले statement मे ,actual parameter मे दो constants को pass किया गया है |
दुसरे statement और तीसरे statement मे ,actual parameter मे एक variable और एक constant को pass किया गया है |
statement-4 मे , actual parameter मे एक expression और variable को pass किया गया है |
statement-5 मे , खुद function और variable को pass किया गया है |
अगर किसी function मे , कोई भी value pass नहीं करने तब function call का syntax है :-
c= function name ( );
इसमें actual parameter मे कोई भी variable ,constant,function और expression नहीं होता है |जैसा:
#include<conio.h>
#include<stdio.h>
int add (int ,int );
void line();
void main( )
{
int a,b ;
printf(“Enter your data”);
scanf(“%d $%d”,&a,&b);
c=add ( a ,  b );
line();
printf(“Sum is %d.”,c);
line();
getch();
}
int add(int e,int f)
{
int sum;
sum=e+f;
return sum;
}
void line()
{
for(i=0;i<=20;i++)
{
printf(“*”);
}
}
इस प्रोग्राम मे , दो user define function है |add() और line() function : add() function मे parameter pass हो रहे है लेकिन line() function मे कोई भी parameter pass नहीं हो रहा है |
आउटपुट होगा :
Enter your data 12 23
*********************
Sum is 35.
*********************

Function Declaration:

किसी function को प्रोग्रम मे use करने से पहले ,Function को प्रोग्राम के header space मे  Declare किया जाता है | इस syntax के 4 parts होते है |इसका syntax है :-
function type function name (parameter list)  ;
इसमें
function type: ये specify करता है की function से किस तरह का आउटपुट return होता है |
function name : ये function का नाम होता है |
Parameter list : ये फ़ुन्क्तीओन मे pass होने वाले parameter की लिस्ट होती है |
किसी function को declare करने की जगह से उस function का scope का पता चलता है :-
Local Scope :
अगर किसी function को function definition मे declare किया जाता है तब इसका scope local होता है |इसे केवल उस function की body मे use किया जा सकता  है |उदहारण के लिए :
#include<conio.h>
#include<stdio.h>
int add (int ,int );
void main( )
{
int a,b ;
printf(“Enter your data”);
scanf(“%d $%d”,&a,&b);
add ( a ,  b );
getch();
}
int add(int e,int f)
{
void line();
int sum;
sum=e+f;
line();
prinf(“Sum  is ;%d”,sum)
line();
}
void line()
{
for(i=0;i<=20;i++)
{
printf(“*”);
}
}
इस उदाहरण मे , line () function को main() function use नहीं कर कर सकते है क्योकि इसका declartion add() function मे किया गया है |ये local function की तरह कार्य करेगा|
आउटपुट होगा :
Enter your data 12 23
*********************
Sum is 35.
*********************
Global Scope :
जब किसी function को main() function उपर declare किया जाता है |तब उस function का PROTOTYPE / SCOPE  global होगा |इसे main function और बाकि के user define function मे use किया जा सकता है |सभी function को main() function से पहले ही declare किया जाना चाहिए |
उदहारण के लिए:
#include<conio.h>
#include<stdio.h>
int add (int ,int );
int mul(int,int);
void line();
void main()
{
int a,b ;
printf(“Enter your data”);
scanf(“%d $%d”,&a,&b);
c=add ( a ,  b );
d=mul (a ,  b );
printf(“Sum is %d.”,c);
line();
printf(“Multiplication is %d.”,d);
getch();
}
int add(int e,int f)
{
int sum;
sum=e+f;
return sum;
}
int mul (int g,int h)
{
int mul;
mul=g*h;
return mul;
}
void line()
{
for(i=0;i<=20;i++)
{
printf(“*”);
}
}
इस उदहारण मे तीन User define functions line(),add() और mul() है |
आउटपुट होगा :
Enter your data 12 23
Sum is 35.
*********************
Multiplication is 276.
Sbistudy

Recent Posts

सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है

सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…

1 day ago

मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the

marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…

1 day ago

राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi

sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…

3 days ago

गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi

gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…

3 days ago

Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन

वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…

3 months ago

polity notes pdf in hindi for upsc prelims and mains exam , SSC , RAS political science hindi medium handwritten

get all types and chapters polity notes pdf in hindi for upsc , SSC ,…

3 months ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now