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

Write a program to calculate simple interest using function , square using function , area of circle , even-odd logic

इसे पहले article मे , user define function को discuss किया गया है | अब इस article मे यूजर define function के कुछ उदाहरनो को discuss करेगे जिससे अप सभी के user define function के concept को अच्छी तरह से समज सके |उदाहरण 1 :
Write a program to calculate simple interest using function .
इस उदाहरण मे , user define function से simple intrest को calculate करने के लिए function को बनाया गया है |

Expalnation
1.सबसे पहले header feild मे int SimpleIntrest(int ,int ,int ) को declare किया गया है | इस declartion से ये define होता है की function SimpleIntrest() से एक value return होती है जिसका त्य्पोए integer है | और इस function मे pass argument की सख्या ‘3’ है और type integer है |
2.उसके बाद main() function मे तीन variable principal , rate , time को declare किया गया है इसमें यूजर द्वारा input की गयी value को assign किया गया है |
3.यूजर द्वारा इन value को input करा लेते है और इन value को  variable principal , rate , time मे assign करा देते है |
4.उसके बाद एक और variable intrest को declare करते है | जिसमे function SimpleIntrest() के द्वार return की value को असिग्न किया जाता है |
5.उसके बाद  intrest की value को display कर देते है |

SimpleIntrest() मे ,
1.सबसे पहले function definition मे SimpleIntrest(int p ,int r, int t) को define किया जाता है | यह पर ‘p’ ‘r’ ‘t’ formal parameter है जिसमे actual parameter principal , rate , time से intial किया जाता है |
2.उसके बाद si= p*r*t ; से simple intrest को calculate कर लेते है |
3.return statement से si की value को main () मे pass कर देते है |

Source Code
#include <iostream>
#include<conio.h>
using namespace std;
// Function prototype (declaration)
int SimpleIntrest(int, int , int );
void  main()
{
int  principal , rate , time ;
cout<<“Enters principal : “;
cin >> principal;
cout<<“Enters rate : “;
cin >> rate;
cout<<“Enters time : “;
cin >> time;
// Function call
float intrest = SimpleIntrest(principal , rate , time);
cout<<“Simple Intrest :”<<intrest;
getch();
}
// Function definition
int SimpleIntrest ( int p ,int r, int t )
{
float si;
si = p*r*t / 100;
return si ;
}

इसका आउटपुट होगा :
Enters principal : 1000
Enters rate : 10
Enters time : 1
Simple Intrest : 100

उदाहरन 2 :
Write a program to calculate square using function .
इस उदाहरण मे , user define function से square को calculate करने के लिए function को बनाया गया है |

Expalnation
1.सबसे पहले header feild मे int square(int) को declare किया गया है | इस declartion से ये define होता है की function square() से एक value return होती है जिसका  type integer है | और इस function मे pass argument की सख्या ‘1’ है और type integer है |
2.उसके बाद main() function मे एक variable number को declare किया गया है इसमें यूजर द्वारा input की गयी value को assign किया गया है |
3.यूजर द्वारा  value को input करा लेते है और इन value को  variable number मे assign करा देते है |
4.उसके बाद एक और variable ‘o’ को declare करते है | जिसमे function square() के द्वार return की value को assign किया जाता है |
5.उसके बाद ‘o’ की value को display कर देते है |

SimpleIntrest() मे ,
1.सबसे पहले function definition मे square(int n ) को define किया जाता है | यह पर ‘n’ formal parameter है जिसमे actual parameter number से intial किया जाता है |
2.उसके बाद output = n*n ; से square को calculate कर लेते है |
3.return statement से output की value को main () मे pass कर देते है |

Source Code
#include <iostream>
#include<conio.h>
using namespace std;
// Function prototype (declaration)
int square(int);
void  main()
{
int  number ;
cout<<“Enter number : “;
cin >> number;
// Function call
int o  = square(number);
cout<<“Square of:”<<number << “is”<<intrest;
getch();
}
// Function definition
int square ( int n)
{
int output;
output = n*n;
return output ;
}

इसका आउटपुट होगा :
Enters number : 10
Square of 10 is 100

उदाहरन 2 :
Write a program to calculate area of circle using function .
इस उदाहरण मे , user define function से area of circle को calculate करने के लिए function को बनाया गया है |

Expalnation
1.सबसे पहले header feild मे int area(int) को declare किया गया है | इस declartion से ये define होता है की function area() से एक value return होती है जिसका  type integer है | और इस function मे pass argument की सख्या ‘1’ है और type integer है |
2.उसके बाद main() function मे एक variable radius को declare किया गया है इसमें यूजर द्वारा input की गयी value को assign किया गया है |
3.यूजर द्वारा  value को input करा लेते है और इन value को  variable radius मे assign करा देते है |
4.उसके बाद एक और variable ‘area’ को declare करते है | जिसमे function area () के द्वार return की value को assign किया जाता है |
5.उसके बाद ‘area ‘ की value को display कर देते है |

area () मे ,
1.सबसे पहले function definition मे area (int r ) को define किया जाता है | यह पर ‘r’ formal parameter है जिसमे actual parameter radius से intial किया जाता है |
2.उसके बाद output = 3.14 *r*r ; से  area को calculate कर लेते है |
3.return statement से output की value को main () मे pass कर देते है |

Source Code
#include <iostream>
#include<conio.h>
using namespace std;
// Function prototype (declaration)
int area (int);
void  main()
{
int  radius  ;
cout<<“Enter Radius : “;
cin >> radius ;
// Function call
float a  = area (radius );
cout<<“Area of Circle :”<< a ;
getch();
}
// Function definition
int area  ( int r)
{
float  output;
output = 3.14*r*r;
return output ;
}

इसका आउटपुट होगा :
Enters Radius : 7
Area of Circle : 154

उदाहरन 1 :
Write a program to calculate even-odd logic using function .
इस उदाहरण मे , user define function से even-odd logic को calculate करने के लिए function को बनाया गया है |

Explanation
1.सबसे पहले header feild मे int check(int) को declare किया गया है | इस declartion से ये define होता है की function check () से एक value return होती है जिसका  type integer है | और इस function मे pass argument की सख्या ‘1’ है और type integer है |
2.उसके बाद main() function मे एक variable number को declare किया गया है इसमें यूजर द्वारा input की गयी value को assign किया गया है |
3.यूजर द्वारा  value को input करा लेते है और इन value को  variable number मे assign करा देते है |
4.उसके बाद एक और variable ‘ flag’ को declare करते है | जिसमे function check () के द्वार return की logic value को assign किया जाता है |
5.उसके बाद flag की value को check किया जाता ही |अगर flag की value ‘1’ होती है तब number is even का message display हो जाता है | अन्यथा number is odd का message print हो जाता है |

check () मे ,
1.सबसे पहले function definition मे  check (int n) को define किया जाता है | यह पर ‘n’ formal parameter है जिसमे actual parameter number से intial किया जाता है |
2.उसके बाद even-odd के लॉजिक को check किया जाता है | अगर variable ‘n’ , 2 से divide होता है तब function से ‘1’ return होता है |
अन्यथा function से ‘0’ return होती है |

Source Code
#include <iostream>
#include<conio.h>
using namespace std;
// Function prototype (declaration)
int check(int);
void  main()
{
int  number ;
cout<<“Enter number : “;
cin >> number;
// Function call
int flag  = check(number);
if(flag == 1)
{
cout<<“Number is even. “;
}
else
{
cout<<“Number is odd. “;
}
getch();
}
// Function definition
int check ( int n)
{
if(n%2 == 0)
{
return 1;
}
else
{
return 0;
}
}

इसका आउटपुट होगा :
Enters number : 10
Square of 10 is 100)

Sbistudy

Recent Posts

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

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

19 hours ago

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

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

3 days ago

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

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

5 days ago

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

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

5 days ago

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

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

5 days ago

FOURIER SERIES OF SAWTOOTH WAVE in hindi आरादंती तरंग की फूरिये श्रेणी क्या है चित्र सहित

आरादंती तरंग की फूरिये श्रेणी क्या है चित्र सहित FOURIER SERIES OF SAWTOOTH WAVE in…

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