Posts

Showing posts with the label Square

C Program to Find Square, Cube and Square Root of a Number किसी संख्या का वर्ग, घन एवं वर्गमूल ज्ञात करने का प्रोग्राम

In C language, mathematical functions are used to calculate the square, cube, and square root of a number. The pow() function calculates powers, while the sqrt() function calculates the square root. सी लैंग्वेज में किसी संख्या का वर्ग, घन तथा वर्गमूल ज्ञात करने के लिए गणितीय फंक्शन्स का प्रयोग किया जाता है। pow() फंक्शन किसी संख्या की घात ज्ञात करता है, जबकि sqrt() फंक्शन वर्गमूल ज्ञात करता है। Formulas सूत्र: Square (वर्ग): (n^2 = n \times n) Cube (घन): (n^3 = n \times n \times n) Square Root (वर्गमूल): (\sqrt{n}) C Program #include <stdio.h> #include <math.h> int main(void) { float n, square, cube, sr; printf("Enter a number: "); scanf("%f", &n); square = pow(n, 2); cube = pow(n, 3); printf("Square of %.2f = %.2f\n", n, square); printf("Cube of %.2f = %.2f\n", n, cube); if (n >= 0) { sr = sqrt(n); printf("Square root of %.2f = %.2f\n", n, sr); } else...