JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: c++ language in hindi

C++ : Library Function in programming language in hindi ,what is Library Function in c++ language

what is Library Function in c++ language , C++ : Library Function in programming language in hindi :-
Function किसी प्रोग्राम का छोटा part होता है जिसे किसी specific task के लिए बनाया जाता है| C++ मे function का विशेष महत्व होता है | क्योकि Oops मे function को विशेष महत्व होता है |इस article मे function के basic को discuss करेगे और आगे function heading के article मे function के advance ascepts को discuss करेगे |
function दो प्रकार के होते है
(i) With Return value
(ii) Without Return Value
Function को आप खुद बना सकता है और इसे किसी C++ library मे भी विशेष functions को देखा सकते है |
Function with Return value
इस category मे एसे function आते है जिसमे किसी output के लिए एक value generate होती है जिसे किसी दुसरे variable मे assign कर सकते है | उदहारण के लिए
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,a;
cout<< “Enter Number”<<endl;
cin>>n;
a=sqrt(n);
cout<<“Square Root  : “<<a<<endl;
getch();
}
इस प्रोग्राम मे , sqrt() एक libarary function है जो की किसी number के square root को calculate किया जाता है | इस प्रोग्राम मे , यूजर द्वारा input किया गया number को sqrt() को pass किया जाता है |इस number का square root calculate किया जाता है |
इस प्रोग्राम मे , a=sqrt(n); statement को function call कहते है | जो की sqrt() function को call करता है |इस प्रोग्राम मे ‘n’ एक argument है जो की function मे पास्ड किये जाने वाले information है जिस पर operation होता है| इस function से square root को calculate किया जाता है और इसके आउटपुट को variable ‘a’ मे assign कर दिया जाता है |
Function Prototype
function prototype function का declaration होता है | ये function मे pass होने वाले arguments और function का नाम को declare करता है |
उदाहरण :
#include<iostream.h>
#include<conio.h>
int squareroot( int );
void main()
{
int n,a;
cout<< “Enter Number”<<endl;
cin>>n;
a= squareroot (n);
cout<<“Square Root  : “<<a<<endl;
getch();
}
int squareroot( int num )
{
return(num*num);
}
यहा पर int squareroot( int ); function declartion है जिसमे
int : Return type को declare करता है |
squareroot : function का नाम है |
(int) : ये function मे pass होने वाले arguments के type को declare करता है |
function declaration को हमशा semicolon से terminate करता है |जब किसी library function को use किया जाता है तब c language मे real number के लिए integer को use किया जाता है |लेकिन c++ मे इस argument के लिए double type को use किया जाता है | जैसे उदाहरण 1 मे sqrt() का function declartion होता है :
double sqrt(double);
इस function declaration को header file मे declare किया जाता है |सभी function का header file मे prototype होते है इसलिए function description को manual और online check किया जाता है |अतः sqrt() function का prototype math.h और cmath मे declare होता है |
function declaration और function definition प्रोग्रामर हमेशा confusion होता है|लेकिन दोनों ही syntax अलग होते है |
function prototype को function मे pass information और function द्वारा return किया जाने वाले information को define करता है |
function definition से function को प्रोग्राम मे add किया जाता है |
Function with multiple arguments
function मे एक या एक से अधिक arguments को pass किया जा सकता है उदहारण के लिए
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,b,a;
cout<< “Enter Base”<<endl;
cin>>n;
cout<< “Enter Power”<<endl;
cin>>n
a=pow(b,n);
cout<<“Square Root  : “<<a<<endl;
getch();
}
इस उदाहरण मे pow() function मे दो arguments को pass किया जाता है | “b” :base ,”n” : power है अतः pow() function मे base के power को calculate किया जाता है |
इसके अलावा कुछ function एसे भी होते है जिसमे कोई argument pass नहीं होता है |उदाहरण के लिए rand() function मे कोई argument pass नहीं होता है |इसका prototype होता है :
int rand( void );
यहा पर void , no argument को declare करता है | लेकिन अगर प्रोग्रामर void को omit कर देता है () को blank छोड़ देता है तब भी prototype उचित होता है |
इसके अलावा एसे function होते है जिसमे कोई return value नहीं  होती है |अगर प्रोग्रामर कोई print() function को produce करता है तब इस function से कोई value return नहीं होती है | केवल data को screen पर print करने के लिए भेजा जाता है | उदाहरण के लिए
#include<iostream.h>
#include<conio.h>
void main()
{
int r;
cout<<“Enter money in Indian currency :” << endl;
cin>>r;
dollar(r);
getch();
}
यहा पर dollar function कोई भी value को return नहीं कर रहा है |ये function यूजर द्वारा input की जाने वाली Indian currency को dollar मे convert करके ,screen पर print कर देता है |
User Define Function
User define function एसे function होते है जिसे यूजर द्वारा define किया जाता है | इसके तीन मुख्य भाग होते है :-
(i)function declaration
(ii)function call
(iii)function definition
उदाहरन के लिए
#include<iostream.h>
#include<conio.h>
int squareroot( int );  // function declaration
void main()
{
int n,a;
cout<< “Enter Number”<<endl;
cin>>n;
a= squareroot (n);  // function calling
cout<<“Square Root  : “<<a<<endl;
getch();
}
int squareroot( int num ) // function definition
{
return(num*num);
}
user define function को C++ : User Define Function मे सार से discuss करेगे |
Sbistudy

Recent Posts

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

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

15 hours ago

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

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

16 hours ago

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

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

2 days ago

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

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

2 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