हेलो दोस्तों !
आज की इस Most important function of math.h header file in C programming-[Hindi] पोस्ट में हम math.h header file के most important functions के बारे में बात करेंगे और जानेंगे की वो कौन से फंक्शन है। तो दोस्तों math.h हैडर फाइल के महत्वपूर्ण फंक्शन्स को जानने के लिए पोस्ट को अंत तक जरूर पढ़े।
इस पोस्ट के मुख्य टॉपिक्स :-
- math.h header file क्या है ?
- math.h header file के important functions .
1. math.h header file क्या है :-
तो दोस्तों math.h header file के important functions को जानने से पहले हम यह जान लेते है की math.h हैडर फाइल क्या है ?
दोस्तों बाकि की हैडर फाइल्स की तरह ही math.h हैडर फाइल भी एक फाइल है जिसके अंदर मैथ से रिलेटेड फंक्शन्स होते है जो डिजिट्स को कैलकुलेट करने का काम करते है। इसका मतलब है की math.h हैडर फाइल में जितने भी फंक्शन है सभी डिजिट्स या नंबर्स को हैंडल करते है कैलकुलेशन करते है।
math.h हैडर फाइल में सभी फंक्शन double type की वैल्यू को return करते है। जब भी हमें math से रिलेटेड किसी भी फंक्शन का यूज़ करना होता है तो हम math.h हैडर फाइल को हमने प्रोग्राम में include करके उस फंक्शन के नाम से हम उस फंक्शन से रिलेटेड काम को करा सकते है। इस हैडर फाइल को अपने C प्रोग्राम में include करने के लिए हमें #include <math.h > लिखना पड़ता है।
2. math.h header file के important functions :-
तो दोस्तों math.h header file के बारे में जानने बाद अब हम यह जान लेते है की math.h हैडर फाइल के important functions कौन से है ?
दोस्तों वैसे तो math.h हैडर फाइल में बहुत सारे फंक्शन्स है। लेकिन हम उन्ही फंक्शन्स के बारे में बात करेंगे जिनका काफी ज्यादा यूज़ किया जाता है और वो काफ़ी important है। तो ये रहे कुछ functions जो काफ़ी ज्यादा यूज़ किये जाते है
- ceil();
- floor();
- fabs();
- fmode();
- sqrt();
- exp();
- cos();
- sin();
- pow();
- log();
1. ceil() function :-
दोस्तों ceil फंक्शन math.h हैडर फाइल का एक महत्वपूर्ण फंक्शन है जिसका यूज़ ज्यादा किया जाता है। यह फंक्शन उस वैल्यू से जो वैल्यू हम इस फंक्शन को पास करते है उसके सबसे पास की उससे बड़ी या उसके बराबर की इन्टिजर वैल्यू को return करता है।
जैसे अगर हम ceil फंक्शन को 9.5 पास करते है तो ceil फंक्शन हमें 10 return करेगा। क्योंकि 9 के सबसे पास की उससे बड़ी वैल्यू 10 है।
Syntax :- double ceil(double x);
Example program of ceil function :-
#include< stdio.h >
#include< math.h >
void main()
{
float a,b;
a=5.6;
b=9.8;
printf("Ceil function result of %.1lf is %.1lf\n",a,ceil(a));
printf("Ceil function result of %.1lf is %.1lf\n",b,ceil(b));
}
Ceil function result of 5.6 is 6.0
Ceil function result of 9.8 is 10.0
2. floor() function :-
दोस्तों floor फंक्शन math.h हैडर फाइल का उतना ही महत्वपूर्ण फंक्शन है जितना की ceil फंक्शन क्योंकि floor फंक्शन ceil फंक्शन का उल्टा(opposite) है। floor फंक्शन उस वैल्यू से जो वैल्यू हम floor फंक्शन को पास करते है उससे छोटी सबसे बड़ी इन्टिजर वैल्यू या उसके बराबर की इन्टिजर वैल्यू को return करता है।
जैसे अगर हम floor फंक्शन को 9.5 पास करते है तो floor फंक्शन हमें 9 ही return करेगा। क्योंकि 9.5 से छोटी सबसे बड़ी इन्टिजर वैल्यू 9 ही है।
Syntax :- double floor(double x);
Example program of floor function :-
#include< stdio.h >
#include< math.h >
void main()
{
float a,b;
a=5.6;
b=9.8;
printf("floor function result of %.1lf is %.1lf\n",a,floor(a));
printf("floor function result of %.1lf is %.1lf\n",b,floor(b));
}
floor function result of 5.6 is 5.0
floor function result of 9.8 is 9.0
3. fabs() function :-
दोस्तों fabs फंक्शन भी math.h हैडर फाइल का एक महत्वपूर्ण फंक्शन है। क्योंकि यह फंक्शन absolute वैल्यू को return करता है। absolute वैल्यू हमेशा ही पॉजिटिव होती है। इसलिए इस फंक्शन का यूज़ हम अक्सर नेगेटिव वैल्यू को पॉजिटिव वैल्यू में कन्वर्ट करने के लिए करते है।
जैसे अगर हम इस फंक्शन को -50 पास करते है तो यह फंक्शन हमें 50 absolute वैल्यू return करेगा जोकि पॉजिटिव वैल्यू होगी।
Syntax :- double fabs(double x);
Example program of fabs function :-
#include< stdio.h >
#include< math.h >
void main()
{
int a,b;
a=-500;
b=-100;
printf("fabs function result of %d is %.1lf\n",a,fabs(a));
printf("fabs function result of %d is %.1lf\n",b,fabs(b));
}
fabs function result of -500 is 500.0
fabs function result of -100 is 100.0 4. fmod() function :-
दोस्तों fmod फंक्शन भी math.h हैडर फाइल का एक महत्वपूर्ण फंक्शन है। fmod फंक्शन किसी वैल्यू का रिमाइंडर return करना है। fmod फंक्शन दो आर्गुमेंट लेता है पहला अगरूमेंट वह होता है जिस नंबर को डिवाइड करना है और दूसरा आर्गुमेंट वह होता है जिस नंबर से डिवाइड करना है। fmode फंक्शन हमें केवल reminder ही return करता है।
Syntax : doube fmod(double x,double y);
Example program of fmod function :-
#include< stdio.h >
#include< math.h >
void main()
{
float a,b;
a=10;
b=20;
printf("Reminder of %lf is %lf\n",a,fmod(a,3));
printf("Reminder of %lf is %lf\n",b,fmod(b,3));
}
Program output :-Reminder of 10.000000 is 1.000000
Reminder of 20.000000 is 2.000000
5.sqrt() function :-
दोस्तों sqrt फंक्शन की मदद से हम किसी भी नंबर का स्क्वायर रुट निकाल सकते है। sqrt फंक्शन एक आर्गुमेंट लेता है। जिस नंबर का हमें स्क्वायर रुट निकालना है हम उस नंबर को sqrt फंक्शन को पास कर देते है और फिर sqrt फंक्शन कैलकुलेशन करके हमें उस नंबर का स्क्वायर रुट निकाल कर return करता है।
Syntax : doube sqrt(double x);
Example program of sqrt function :-
#include< stdio.h >
#include< math.h >
void main()
{
float a,b;
a=50;
b=100;
printf("Square root of %lf is %lf\n",a,sqrt(a));
printf("Square root of %lf is %lf\n",b,sqrt(b));
}
Square root of 50.000000 is 7.071068
Square root of 100.000000 is 10.000000
Program explanation video :-
दोस्तों अगर आप इन फंक्शन्स से रिलेटेड वीडियो देखना चाहते है। तो आप हमारी वीडियो देख सकते है जिसमें हमने ऊपर के पांच फंक्शन्स के साथ उनके प्रोग्राम को भी समझाया है। तो दोस्तों वीडियो को जरूर देखें और वीडियो पसंद आये तो लाइक जरूर करें और प्रोग्रामिंग से रिलेटेड videos के लिए चैनल को भी सब्सक्राइब जरूर करें।
वीडियो देखने के लिए यहाँ क्लिक करें।
6. exp() function :-
दोस्तों exp फंक्शन एक ऐसा फंक्शन है जो हमें उस वैल्यू पर उसी वैल्यू की पावर लगाकर वैल्यू को बढ़ाकर return करता है। जैसे अगर हम exp फंक्शन को x वैल्यू पास करते है तो यह फंक्शन x वैल्यू को x की पावर लगाकर वैल्यू को बढ़ाकर return करता है। exp फंक्शन केवल एक आर्गुमेंट लेता है। आप इस फंक्शन को example प्रोग्राम की मदद से अच्छी तरह समझ पाएंगे।
Syntax : doube exp(double x);
Example program of exp function :-
#include< stdio.h >
#include< math.h >
void main()
{
float a,b;
a=5;
b=4;
printf("exp function result of %lf is %lf\n",a,exp(a));
printf("exp function result of %lf is %lf\n",b,exp(b));
}
Program output :-exp function result of 5.000000 is 148.413159
exp function result of 4.000000 is 54.598150
7.cos() function :-
दोस्तों cos फंक्शन math.h हैडर फाइल एक महत्वपूर्ण फंक्शन माना जाता है। cos फंक्शन cosin का एंगल radians में निकालने का काम करता है। रेडियंस एक तलीय कोण के मापन की मानक इकाई है। रेडियंस डिग्री की तरह ही कोण मापन की एक इकाई है। cos फंक्शन एक आर्गुमेंट लेता है।
Syntax : doube cos(double x);
Example program of cos function :-
#include < stdio.h >
#include < math.h >
#define PI 3.141592654
void main()
{
double x = 30,y=20,result,result1;
x = (x * PI) / 180;
result = cos(x);
printf("cos of %.2lf radian = %.2lf\n", x, result);
y = (y * PI) / 180;
result1 = cos(y);
printf("cos of %.2lf radian = %.2lf\n", y, result1);
}
Program output :-cos of 0.52 radian = 0.87
cos of 0.35 radian = 0.94
8. sin() function :-
दोस्तों sin फंक्शन भी cos फंक्शन की तरह ही math.h हैडर फाइल एक महत्वपूर्ण फंक्शन माना जाता है। sin फंक्शन sine का एंगल radians में निकालने का काम करता है। रेडियंस एक तलीय कोण के मापन की मानक इकाई है। रेडियंस डिग्री की तरह ही कोण मापन की एक इकाई है। cos फंक्शन की तरह ही sin फंक्शन भी एक ही आर्गुमेंट लेता है।
Syntax : doube sin(double x);
Example program of sin function :-
#include < stdio.h >
#include < math.h >
void main()
{
double num,num1;
num = 2.3;
num1=1.5;
printf("sin(%.2lf) = %.2lf\n",num,sin(num));
printf("sin(%.2lf) = %.2lf\n",num1,sin(num1));
}
Program output :-sin(2.30) = 0.75
sin(1.50) = 1.00
9. pow() function :-
दोस्तों pow फंक्शन का पूरा नाम power है। pow फंक्शन exp फंक्शन की तरह ही वैल्यू को पावर लगाकर बढ़ाकर return करता है। लेकिन pow फंक्शन exp फंक्शन से थोड़ा अलग है। exp फंक्शन उसी वैल्यू की पावर लगाकर वैल्यू को बढ़ाकर return करता है जबकि pow फंक्शन एक वैल्यू को किसी दूसरी वैल्यू की पावर लगाकर वैल्यू को बढ़ाकर return करता है।
Syntax : doube pow(double x,double y);
Example program of pow function :-
#include < stdio.h >
#include < math.h >
void main()
{
double x,y;
x=5;
y=4;
printf("%.1f^%.1f is %.2f\n",x,y,pow(x,y));
printf("%.1f^%.1f is %.2f\n",y,x,pow(y,x));
}
Program output :-5.0^4.0 is 625.00
4.0^5.0 is 1024.00
10. log function :-
दोस्तों log फंक्शन भी एक महत्वपूर्ण फंक्शन होता है। log फंक्शन किसी भी नंबर का natural logarithm return करता है।अगर आपने मैथ में लोगरिथ्म को पढ़ा होगा तो आप इसे अच्छी तरह समझ गए होंगे। नेचुरल लोगरिथ्म में base 'e' होता है 'e' की वैल्यू लगभग 2.718281828 के बराबर होती है। log function केवल एक आर्गुमेंट लेता है।
Syntax : doube log(double x);
Example program of log function :-
#include < stdio.h >
#include < math.h >
void main()
{
double num = 5.6, result;
double num1 = 6.5;
result = log(num);
printf("log(%.1f) = %.2f\n", num, result);
result=log(num1);
printf("log(%.1f) = %.2f\n", num1, result);
}
Program output :- log(5.6) = 1.72
log(6.5) = 1.87
इन पोस्ट को भी पढ़े :-
- stdlib.h हैडर फाइल के महत्वपूर्ण फंक्शन्स।
- stdio.h हैडर फाइल के महत्वपूर्ण फंक्शन्स।
- 5 most important header file in C
Author :- तो दोस्तों अब हमारी यह Most important function of math.h header file in C programming-[Hindi] पोस्ट ख़त्म होती है हम आशा करते है की आपको हमारी यह पोस्ट जरूर पसंद आई होगी और आप math.h header file के important functions को जान गए होंगे। तो दोस्तों आज के लिए बस इतना ही फिर मिलेंगे ऐसी ही किसी और इंटरेस्टिंग पोस्ट में तब तक के लिए अलविदा !
0 Comments
Do not enter any spam comments please.