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

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

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

23 hours ago

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

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

24 hours ago

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

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

3 days ago

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

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

3 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