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++ : Inline Function in hindi , what is Inline Function in c++ language example program

what is Inline Function in c++ language example program , C++ : Inline Function in hindi :-

इससे पहले के article मे function को discuss किया जाता है | अब इस article मे  c++ की एक और property को discuss करेगे | जिसे inline function कहते है | inline function के कार्य function के सामान होता है |

Inline Function

c++ मे inline function का use , function की speed को बढ़ाने के लिए किया जाता है | inline function और नार्मल function मे कोई भी difference नहीं होता है | लेकिन इन function को call करने के लिए नए method को use किया जाता है | inline function और normal function मे difference को समजने के लिए निन्म पॉइंट्स को consider किया जाता है |

किसी प्रोग्राम को execute करने  के  लिए बहुत सारे machine codes को use किया जाता है |  जब किसी प्रोग्राम को start किया जाता है तब operating सिस्टम , कंप्यूटर memory मे instructions को लोड करता है | प्रत्येक instructions का कंप्यूटर memory मे space को allocate किया जाता है | कंप्यूटर control, इन  instructions one by one execute करता है | लेकिन अगर कोई braching statement आ जाता है तब  कुछ instructions को स्किप भी किया जा सकता है | और कोई forward और backward instructions मे jump भी किया जा सकता है | 

जब Normal function को call किया जाता है तब प्रोग्राम control , main() के instructions को function के instructions मे jump होता है और instructions के execute होने के बाद वापिस main()मे return हो जाता है | इस प्रोसेस को और अच्छी तरह से discuss करते है | जब प्रोग्राम control function call के instructions तक पहुचता है तब instructions के memory address को function call के बाद load हो जाता है |  अतः function का argument को stack मे assign किया जाता है | और प्रोग्राम control को function के instructions मे jump हो जाता है |और प्रोग्राम control function के instructions के बाद stack मे store instructions अपर jump हो जाता है | 

c++ inline function का method , नार्मल function से अलग अलग होता है | C++ language मे , inline function मे  main() के साथ दूसरा function inline रहता है | अतः inline function को प्रोग्राम मे  function call के साथ replace किया जाता है |inline function से , जब inline function को call किया जाता है तब प्रोग्राम control, inline function पर jump नहीं होता है |  इसलिए प्रोग्राम की speed बढ़ जाती है | और inline function से memory loss को भी कम किया जाता है |

inline function को use करने के लिए बहुत पॉइंट्स ध्यान मे रखना पड़ता है | inline function को execute करने के लिए लगा time तो बढ़ जाता है |अगर inline function की length बहुत कम होती है  तब inline function को use करना बेकार होता है |  इसलिए बड़े बड़े function के लिए inline function को use करना चाहये जिससे प्रोग्राम मे memory occupation और time दोनों ही कम हो जाये | 

inline function को use करने के लिए निन्म स्य्ताक्स को use किया जाता है :-

inline function_name (argument);

inline function_name (argument)

{

function_body ;

इस syntax मे function declartion और function definition मे inline keyword को use किया जाता है | 

इस का उदाहरन होता है :

इस उदाहरण मे , inline function से  calculator को बनाया गया है |

Expalnation

सबसे पहले यूजर द्वारा choice को input किया जाता है | 

Enter ‘+’ for addition

Enter ‘-‘ for subtraction

Enter ‘*’ for multiplication

Enter ‘/’ for division

उसके बाद यूजर से choice को input करा लेते है | और इसके बाद  यूजर से values को input करा लेते है | 

choice को switch statement मे pass किया जाता है | उस आधार पर function को कैल्ल किया जाता है |

inline add() मे ,

inline add() function मे दो value को addition किया जाता  है | और आउटपुट की value को display किया जाता है |

inline sub() मे ,

inline sub () function मे दो value को  subtraction किया जाता  है | और आउटपुट की value को display किया जाता है |

inline mul() मे ,

inline mul() function मे दो value को multilication किया जाता  है | और आउटपुट की value को display किया जाता है |

inline div() मे ,

inline div () function मे दो value को division किया जाता  है | और आउटपुट की value को display किया जाता है |

Source Code

#include <iostream>

#include<conio.h>

using namespace std;

inline void  add(int, int );

inline void sub(int, int );

inline void mul(int, int );

inline void div(int, int );

void main() 

{

int number1 , number2 ;

char choice ;

cout<<“Enter ‘+’ for addition”<<endl<<“Enter ‘-‘ for subtraction”<<endl<<“Enter ‘*’ for multiplication”,,endl<<“Enter ‘/’ for division”<<endl;

cout<<“Enter choice : “;

cin >> choice;

cout<<“Enter number1 : “;

cin >> number1;

cout<<“Enters number2 : “;

cin >> number2;

switch(choice)

{

case ‘+’ :

add(number1,number2);

break;

case ‘-‘ :

sub(number1,number2);

break;

case ‘*’ :

mul(number1,number2);

break;

case ‘/’ :

div(number1,number2);

break;

default :

cout<<“invalid choice “;

break;

}

getch();

}

// Function definition

inline void add(int a, int b)

{

int output;

output = a + b;

cout<<“Output : “<<output;

}

// Function definition

inline void div(int a, int b)

{

int output;

output = a / b;

cout<<“Output : “<<output;

}

// Function definition

inline void sub(int a, int b)

{

int output;

output = a – b;

cout<<“Output : “<<output;

}

// Function definition

inline void mul(int a, int b)

{

int output;

output = a * b;

cout<<“Output : “<<output;

}

इस उदहारण मे चार inline functions को use किया जाता है  |

 जब add() को call किया जाता है | add() की body main() मे add() call statement पर copy होता है | और execute होता है | इस प्रोसेस मे प्रोग्राम control को shift नहीं किया जाता है |

 जब sub() को call किया जाता है | add() की body main() मे sub() call statement पर copy होता है | और execute होता है | इस प्रोसेस मे प्रोग्राम control को shift नहीं किया जाता है |

 जब mul() को call किया जाता है | add() की body main() मे  mul() call statement पर copy होता है | और execute होता है | इस प्रोसेस मे प्रोग्राम control को shift नहीं किया जाता है |

 जब div() को call किया जाता है | add() की body main() मे  div() call statement पर copy होता है | और execute होता है | इस प्रोसेस मे प्रोग्राम control को shift नहीं किया जाता है |

इसका आउटपुट होगा :

Enter ‘+’ for addition

Enter ‘-‘ for subtraction

Enter ‘*’ for multiplication

Enter ‘/’ for division

Enter choice : –

Enter number1 : 24

Enter number2 : 12

output : 12

इस article मे inline function को discuss किया गया है अब आगे के article मे class और object को discuss करेगे |

Sbistudy

Recent Posts

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

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

2 days ago

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

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

4 days ago

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

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

6 days ago

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

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

6 days ago

elastic collision of two particles in hindi definition formula दो कणों की अप्रत्यास्थ टक्कर क्या है

दो कणों की अप्रत्यास्थ टक्कर क्या है elastic collision of two particles in hindi definition…

6 days 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