Math Function in C language ? – C language मे math function क्या है ?
C प्रोग्रामिंग लैंग्वेज mathematical operations को perform करने के हमे math फंक्शन provide करता है। ये फंक्शन <math.h> header file मे define रहता है। इस फंक्शन के अंदर बहुत से methods होते है जिनकी सहायता से हम आसानी से mathematical operations को perform कर सकते है।`
<math.h> header file में बहुत सारे methods होते है लेकिन हम यहाँ कुछ महत्वपूर्ण method को ही पढ़ेंगे।
- ceil (number) :
यह method दिए गए नंबर को rounds up करता है। और दिए गए नंबर से बड़ी या बराबर value को return करता है। return की गयी वैल्यू integer value होती है। - floor (number) :
यह method दिए गए नंबर को rounds up करता है। और दिए गए नंबर से छोटी या बराबर value को return करता है। return की गयी वैल्यू integer value होती है |
Example of ceil (number) & floor (number) method
Source Code : #include<stdio.h> #include <math.h> int main(){ // ceil()method printf("\n%f",ceil(7.6)); printf("\n%f",ceil(6.3)); // floor()method printf("\n%f",floor(3.8)); printf("\n%f",floor(2.2)); return 0; } Output : // ceil()method O/P 8.0000 7.0000 // floor()method O/P 3.0000 2.0000
- sqrt(number) :
यह method दिए गए नंबर के square root को return करता है | - pow(base, exponent) :
यह method दिए गए नंबर के power को return करता है | - abs(number) :
यह method दिए गए नंबर के absolute value को return करता है |
Example of sqrt (number) & pow (base, exponent) & abs (number) method
Source Code : #include<stdio.h> # #include <math.h> int main(){ // sqrt () method printf("\n%f",sqrt(49)); printf("\n%f",sqrt(121)); // pow () method printf("\n%f",pow(2,5)); printf("\n%f",pow(3,3)); // abs () method printf("\n%d",abs(-12)); return 0; } OUTPUT : // sqrt () method O/P 7.00000 11.00000 // pow () method O/P 32.00000 27.00000 // abs () method O/P 12
RECOMMENDED POST