JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: C Language in hindi

C99 – Feature (Part -3) : function related modification in c language in hindi , फंक्शन सम्बंधित मॉडिफिकेशन

फंक्शन सम्बंधित मॉडिफिकेशन , C99 – Features : function related modification in c language in hindi :-
C99 – Feature (Part -1) or C99 – Feature (Part -2) मे , हमने variable और array से related modification को पढ़ा |अब इस article मे function से related modification को पढ़गे |
C 99 मे function को implement करके के तरीके मे काफी changes आये है |इसमें include होता है :-
1.Default of int rule को हटा दिया गया है |
2.Implicit function declaration को भी हटा दिया गया है |
3.return function की complusy को भी हटा दिया गया है |
4. function inline facility1. Elimination of Default of int rule
.जब किसी function को declare किया जाता है |इसका syntax होता है :
return type function name (parameter details);
इस syntax मे :
return type : ये declare करता है की function से किसी प्रकार के data type return होगा |
function name : ये function का नाम है|
parameter details: ये सेक्शन मे function मे pass होने वाले variable के data type को declare किया जाता है |

C language मे , अगर return type को declare नहीं करते है तब इसका default return type integer होगा | जैसे
#include<stdio.h>
#include<conio.h>
add(int , int );
void main()
{
int a ,b,c;
printf(“Data”);
scnaf(“%d %d”,&a &b);
c=add(a,b);
printf(“Sum = %d”, c);
getch ();
}
add (int e,int f)
{
int sum;
sum=e+f;
return(sum);
}
इस उदाहरण मे , function add() के declaration मे return type को declare नहीं किया गया है |add() function से integer return हो रही |और function का default return type  integer type है अतः ये प्रोग्राम बिना किसी error के run हो जाता है |
लेकिन अगर इस function को C99 मे run करे तो error आ जाती है |इस error को दूर करने के लिए function के declaration मे return type को int से declare करना पड़ता है |अतः
प्रोग्राम :- C99
#include<stdio.h>
#include<conio.h>
int add(int , int );
void main()
{
int a ,b,c;
printf(“Data”);
scnaf(“%d %d”,&a &b);
c=add(a,b);
printf(“Sum = %d”, c);
getch ();
}
int add (int e,int f)
{
int sum;
sum=e+f;
return(sum);
}

इसके अलावा default integer का rule function parameter मे भी omit कर दिया गया है |क्योकि अगर किसी function parameter  को function declaration मे उसके qualifier से  declare किया जाता है  |तब उस parameter का default type integer होता है |c language मे usually तीन qualifier मुख्य होते है |
1.Constant: ये भी एक नार्मल variable ही होते है लेकिन इनके value constant होती है यानि change नहीं हो सकती है |इसका syntax const होता है |
2.Register : ये भी नार्मल variable होते है लेकिन ये memory मे store नहीं होते है बल्की कंप्यूटर memory बने register मे store होते है |इसका syntax register होता है |
3.volatile: जब किसी variable को volatile declare किया जाता है तब इसकी value को प्रोग्राम मे change नहीं कर सकते है | इसे केवल सिस्टम से change हो सकता है |
उदाहरण के लिए :-
C language मे ,
#include<stdio.h>
#include<conio.h>
int mul(  );
void main()
{
int c,a,b;
printf(“Data”);
scnaf(“%d %d”,&a &b);
c=mul(a,b);
printf(“Multiplication  = %d”, c);
getch ();
}
mul ( register e, register f)
{
int mul;
mul =e*f;
return(mul);
}

इस उदहारण मे , function definition मे variable को register declare किया गया है अतः इसका default type integer भी है लेकिन ये function C99 मे run हो सकता है |
इसके लिए निन्म modification करना पड़ता है :-
C99 language मे ,
#include<stdio.h>
#include<conio.h>
int mul(  );
void main()
{
int c,a,b;
printf(“Data”);
scnaf(“%d %d”,&a &b);
c=mul(a,b);
printf(“Multiplication  = %d”, c);
getch ();
}
mul ( register int  e, register int  f)
{
int mul;
mul =e*f;
return(mul);
}

2.Explicit function declaration
C 99 मे function declaration को declare करना भी जरुरी नहीं है \जैसे c++ मे function को declare किये बिना use किया जा सकता है |उसी प्रकार C99 मे function को बिना declare किये बिना use कर सकते है |
3.Restrictions of return statement
C language ,जब किसी function के declaration मे return type को declare किया जाता है और अगर function body मे return statement नहीं है |तो भी प्रोग्राम मे कोई भी error नहीं आएगी |लेकिन C99 मे , अगर function declaration मे return type है तब function की body से value return होनी चाहिए |
उदाहरण के लिए:
#include<stdio.h>
#include<conio.h>
int sub(int , int );
void main()
{
int a, b;
printf(“Data”);
scanf(“%d %d”,&a &b);
sub(a,b);
getch();
}
int sub(int e,int f)
{
int diff;
diff=e-f;
printf(“Difference = %d”,diff);
return;
}
ये उदहारण C language के लिए सही है और run भी होगा |लेकिन C 99 मे , ये प्रोग्राम run नहीं हो पायेगा |
इसके लिए:
#include<stdio.h>
#include<conio.h>
int sub(int , int );
void main()
{
int a, b, c;
printf(“Data”);
scanf(“%d %d”,&a &b);
c=sub(a,b);
printf(“difference is %d”,c);
getch();
}
int sub(int e,int f)
{
int diff;
diff=e-f;
return(diff);
}
4.Function Inline
ये property को c++ से लिए गया | इसमें किसी function को call नहीं किया जाता है बल्कि main() function मे झा पर function call statement के स्थान पर function का code copy हो जाता है |
in short
कोम्प्लिएर का control main() function मे ही होता है |
उदाहरण के लिए:
#include<stdio.h>
#include<conio.h>
void  div(int , int );
void main()
{
int a, b, c;
printf(“Data”);
scanf(“%d %d”,&a &b);
div (a,b);
getch();
}
inline void  div (int e,int f)
{
float div;
div=e/f;
printf(“division is %f”,div);
}
इस उदहारण मे , div function की body main function मे जहा पर div() को लिखा गया है पर copy हो जायेगा |और operation perform हो जायेगा |
inline function का सबसे अच्छा असर execution time पर पड़ता है |इससे call-return प्रोसेस मे लगना वाला time बहुत ही कम हो जाता है |
Sbistudy

Recent Posts

Question Tag Definition in english with examples upsc ssc ias state pcs exames important topic

Question Tag Definition • A question tag is a small question at the end of a…

2 weeks ago

Translation in english grammer in hindi examples Step of Translation (अनुवाद के चरण)

Translation 1. Step of Translation (अनुवाद के चरण) • मूल वाक्य का पता करना और उसकी…

2 weeks ago

Report Writing examples in english grammer How to Write Reports explain Exercise

Report Writing • How to Write Reports • Just as no definite rules can be laid down…

2 weeks ago

Letter writing ,types and their examples in english grammer upsc state pcs class 12 10th

Letter writing • Introduction • Letter writing is an intricate task as it demands meticulous attention, still…

2 weeks ago

विश्व के महाद्वीप की भौगोलिक विशेषताएँ continents of the world and their countries in hindi features

continents of the world and their countries in hindi features विश्व के महाद्वीप की भौगोलिक…

2 weeks ago

भारत के वन्य जीव राष्ट्रीय उद्यान list in hin hindi IAS UPSC

भारत के वन्य जीव भारत में जलवायु की दृष्टि से काफी विविधता पाई जाती है,…

2 weeks 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