JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi sociology physics physical education maths english economics geography History

chemistry business studies biology accountancy political science

Class 12

Hindi physics physical education maths english economics

chemistry business studies biology accountancy Political science History sociology

Home science Geography

English medium Notes

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Class 12

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Categories: c++ language in hindi

C++ : User Define Function Return Statement in hindi , what is User Define Function Return Statement in c++ language

इससे पहले के article मे function का basic staruture को discuss किया है | अब इस article मे function मे argument को pass करने के तरीके और return statement को discuss करेगे |

Argument

किसी programing language , argument का मतलब उस data से define करता है जिसे function मे pass किया जाता है | अतः argument किसी variable को define करता है जिसे function मे pass किया जाता है | ये main() function से data value को यूजर define function मे pass किया जाता है | निन्म उदाहरन से argument को समजा जा सकता है :-

#include

#include

using namespace std;

// Function prototype (declaration)

int sub(int, int);

int main()

{

int num1, num2, sub;

cout<<“Enters two numbers : “; cin >> num1 >> num2;

// Function call

sub = sub(num1, num2);

cout << “Output : ” << sum; getch(); } // Function definition int sub(int a, int b) { int output; output = a – b; // Return statement return output; } उपर के उदाहरन मे , दो variable num1 और num2 को function sub() मे pass किया जाता है | in variable को function sub () calling statament मे pass किया गया है | call statement मे pass किये गये argument को actual parameter कहते है | function defintion मे variable ‘a’ और ‘b’ मे call statement मे pass variable को initial किया गया है | in variable को user define function मे use किया जाता है | अतः variable ‘a’ और ‘b’ को formal parameter कहते है | इसका आउटपुट होगा : Enters two numbers : 12 2 Output : 10 Argument Pass के rules 1.actual parameter और formal parameter की number सामान होती है | 2.actual parameter और formal parameter के type भी सामान होती है | अतः पहले actual parameter के type , formal parameter से matched होना चाहिए | और second actual parameter का type , फोम्मल parameter से match होता है | 3.किसी function को argument के बिना भी call किया जा सकता है | argument को pass करने का desicion प्रोग्रामर पर होता है | 4.किसी default argument को function call statement मे पस्सेद्क किया जा सकता है | default parameter , वे variable होते है जिसकी value default होती है | 5.function मे अलग अलग type के variable को pass किया जा सकता है | इन rules को समजने के निन्म उदाहरन को consider करेगे : #include

#include

using namespace std;

// Function prototype (declaration)

int mul(int, int);

int main()

{

int num1, num2, m;

cout<<“Enters two numbers : “; cin >> num1 >> num2;

// Function call

m = mul(num1, num2);

cout << “Output : ” << m; getch(); } // Function definition int mul(int a, int b) { int output; output = a * b; // Return statement return output; } इस उदाहरन मे mul() एक user define function है जिससे multiplication task को किया गया है | function call statement mul(num1, num2); मे pass actual parameter की सख्या ‘2’ है और function definition statement मे भी formal parameter की सख्या ‘2’ है | function call statement mul(num1, num2); मे pass actual parameter की type integer है और function definition statement मे भी formal parameter का type भी integer है | इसका आउटपुट होगा : Enters two numbers : 12 2 Output : 24 Return Statement कोई user define function मे केवल एक value को return किया जा सकता है | इस value को call function statement से किसी variable मे assign किया जा सकता है | return statement से user define function के द्वारा value को main() function मे pass की जाती है | लेकिन number ऑफ़ value केवल एक होती है | जब किसी यूजर define function के द्वारा कोई value pass की जाती है तब यूजर define function का type return type के सामान होता है | निन्म उदाहरन मे return statement को use किया गया है : #include

#include

using namespace std;

// Function prototype (declaration)

int div(int, int);

int main()

{

int num1, num2 ,d;

cout<<“Enters two numbers : “; cin >> num1 >> num2;

// Function call

d= div(num1, num2);

cout << “Output : ” << m; getch(); } // Function definition int div(int a, int b) { int output; output = a / b; // Return statement return output; } इस उदहारण मे निन्म पॉइंट्स को consider करना है : div() function से integer value को return किया जाता है इसलिए user define function div() का type ‘int’ है | इसके अलावा function द्वारा integer value को return किया जाता है इसलिए main() function जिस भी variable मे value को assign किया जाता है उसका type भी integer होना चाहिए | इस उदहारण मे return output; return statement है | इस उदहारण मे आउटपुट की value को main() function मे return किया जाता है| main() function मे variable आउटपुट की value variable div मे assign किया जाता है | इसका आउटपुट होगा : Enters two numbers : 12 2 Output : 6 किसी यूजर define function मे return statement होना जरुरी नहीं है | ये प्रोग्रामर पर depend करता है | अगर user define function से कोई भी value return नहीं होती है तब user define function का type void होता है | इसका उदाहरन निन्म है : #include

#include

using namespace std;

// Function prototype (declaration)

void add(int, int);

int main()

{

int n1, n2 ,sum;

cout<<“Enters value1 : “; cin >> n1;

cout<<“Enters value12 : “; cin >> n2;

// Function call

add(n1, n2);

getch();

}

// Function definition

void add(int a, int b)

{

int output;

output = a + b;

cout<<“Output : “<<output; }=”” इस=”” उदाहरन=”” मे=”” user=”” define=”” function=”” से=”” कोई=”” भी=”” value=”” return=”” नहीं=”” हो=”” रही=”” है=”” इसलिए=”” का=”” type=”” void=”” |=”” और=”” main=”” call=”” को=”” डायरेक्ट=”” ही=”” किया=”” article=”” ,=”” argument=”” pass=”” statement=”” discuss=”” अब=”” आगे=”” के=”” करेगे=”” <=”” p=””></output;>

Sbistudy

Recent Posts

द्वितीय कोटि के अवकल समीकरण तथा विशिष्ट फलन क्या हैं differential equations of second order and special functions in hindi

अध्याय - द्वितीय कोटि के अवकल समीकरण तथा विशिष्ट फलन (Differential Equations of Second Order…

21 hours ago

four potential in hindi 4-potential electrodynamics चतुर्विम विभव किसे कहते हैं

चतुर्विम विभव (Four-Potential) हम जानते हैं कि एक निर्देश तंत्र में विद्युत क्षेत्र इसके सापेक्ष…

4 days ago

Relativistic Electrodynamics in hindi आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा

आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा Relativistic Electrodynamics in hindi ? अध्याय : आपेक्षिकीय विद्युतगतिकी…

6 days ago

pair production in hindi formula definition युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए

युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए pair production in hindi formula…

1 week ago

THRESHOLD REACTION ENERGY in hindi देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा

देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा THRESHOLD REACTION ENERGY in hindi…

1 week 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