JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: C Language in hindi

User Define Function : Return Type or Basic Examples in hindi यूजर डिफाइन फंक्शन हिंदी में

यूजर डिफाइन फंक्शन हिंदी में User Define Function : Return Type or Basic Examples in hindi in c computer language :-
पिछले articles मे हमने function का syntax को study किया है |लेकिन हमने return statement के  type को स्टडी नहीं किया है अब इस article मे हम return statement और basic प्रोग्राम(simple interest ,area ,even or odd,bigger value among three values ) के प्रोग्राम को देखगे |Return Statement :
Function difination मे return statement का अलग से महत्व है |return statement से user define function से केवल एकक value को main function मे transfer कर सकते है |इसका syntax है :-

return();      और    return(expression);

return statement दो प्रकार के होते है :-
Plain Return Statement :
return() को Plain Return Statement कहते है |ये statement main() function मे कोई value pass नहीं करता है |इसका मतलब है की function पूरा हो चूका है |जब भी Plain Return Statement आ जाता है उसके बाद COMPILER का  control main function मे चला जाता है |
उदहारण के लिए :
#include<stdio.h.
#include<conio.h.
void large(int,int);
void main()
{
int a,b;
printf(“Enter your data”);
scanf(“%d %d”,&a,&b);
large(a,b);
printf(“End of This Program”);
getch();
}
int large (int c, int d)
{
if(c<d)
{
printf(“%d is less than %d. “,c,d);
return();
}
else
{
printf(“%d is less than %d. “,d,c);
return();
}
}
इस उदाहरण मे , function large() मे जब condition (c<d) true होगा तब printf(“%d is less than %d “,c,d); execute होगा और complier का control main() function मे  मूव हो जाता है |और printf(“End of This Program”); execute होता है |
आउटपुट होगा :
Enter your data 34 45
34 is less than 45.
End of This Program

Return(expression);
इस statement से किसी expression के आउटपुट को main() function मे pass होता है |उदाहरण के लिए:
#include<stdio.h>
#include<conio.h.
float power(int,int);
void main()
{
int a,b,c,d;
printf(“Enter your data”);
scanf(“%d %d”,&a &b);
d=c+power(a,b);
printf(“Expression Output=%d”,)
Return statement मे constant value को भी पास कर सकते है |Return statement का default data type integer होता है |जब प्रोग्रामर किसी विशेष data type को pass करना चाहता है तब use function definition के header portion मे function type को change करना पड़ेगा |उदाहरण के लिए :
#include<stdio.h>
#include<conio.h>
void large(int,int);
void main()
{
int a,b,i;
printf(“Enter your data”);
scanf(“%d %d”,&a,&b);
i=large(a,b);
if(i==1
{
printf(“%d is less than %d. “,a,b);
}
else
{
printf(“%d is less than %d. “,b,a);
getch();
}
int large (int c, int d)
{
if(c<d)
{
return(1);
}
else
{
return(0);
}
}
इस उदाहरण मे , जब condition true होगी तब ‘1’ pass होगा और false होने पर ‘0’ pass होगा |

आउटपुट होगा :
Enter your data 56 76 
56 is less than 76.

अब हम कुछ basic प्रोग्राम को function से बनयेगे :
/*Program For
Calculate Simple Interest */
#include<stdio.h>
#include<conio.h>
int SI(int,Float,int );
void main()
{
int P,R,T;
printf(“Enter
Principal”);
scanf(“%d
“,&P);
printf(“Enter
Rate”);
scanf(“%f
“,&R);
printf(“Enter
Time”);
scanf(“%d
“,&T);
SI(P,R,T);
printf(“Thank
You!”)
getch();
}
int SI( int a,int b,int
c)
{
float s;
s=P*R*T/100;
Printf(“Simple
Intrest Is %f”,s);
return();
}
आउटपुट होगा :
Enter Principal 1000
Enter Rate 2.5
Enter Time 2
Simple Intrest is 50
Thank You!
/*Program
For Calculate Area of Circle */
#include<stdio.h>
#include<conio.h>
#define pi 22.7
float area(int);
void main()
{
int radius;
float area;
printf(“Enter
radius”);
scanf(“%d
“,&radius);
area=area(r);
printf(“Area is
%2f”,area);
printf(“Thank
You!”)
getch();
}
float area(int a)
{
float s;
s=pi*a*a;
return(s);
}
आउटपुट होगा :
Enter radius 5
Area is 567.50
Thank You!
/*Program
For find a number और not  */
#include<stdio.h>
#include<conio.h>
void even(int);
void main()
{
int number;
printf(“Enter
Number”);
scanf(“%d
“,&number);
even(number);
getch();
}
void even(int a)
{
if(a/2==0)
{
printf(“Number is Even.”)
return();
}
else
{
printf(“Number is not Even.”)
return();
}
}
आउटपुट होगा :
Enter number 5
Number is not Even.
Sbistudy

Recent Posts

सारंगपुर का युद्ध कब हुआ था ? सारंगपुर का युद्ध किसके मध्य हुआ

कुम्भा की राजनैतिक उपलकियाँ कुंमा की प्रारंभिक विजयें  - महाराणा कुम्भा ने अपने शासनकाल के…

4 weeks ago

रसिक प्रिया किसकी रचना है ? rasik priya ke lekhak kaun hai ?

अध्याय- मेवाड़ का उत्कर्ष 'रसिक प्रिया' - यह कृति कुम्भा द्वारा रचित है तथा जगदेय…

4 weeks ago

मालकाना का युद्ध malkhana ka yudh kab hua tha in hindi

malkhana ka yudh kab hua tha in hindi मालकाना का युद्ध ? मालकाना के युद्ध…

2 months ago

कान्हड़देव तथा अलाउद्दीन खिलजी के संबंधों पर प्रकाश डालिए

राणा रतन सिंह चित्तौड़ ( 1302 ई. - 1303 ) राजस्थान के इतिहास में गुहिलवंशी…

2 months ago

हम्मीर देव चौहान का इतिहास क्या है ? hammir dev chauhan history in hindi explained

hammir dev chauhan history in hindi explained हम्मीर देव चौहान का इतिहास क्या है ?…

3 months ago

तराइन का प्रथम युद्ध कब और किसके बीच हुआ द्वितीय युद्ध Tarain battle in hindi first and second

Tarain battle in hindi first and second तराइन का प्रथम युद्ध कब और किसके बीच…

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