C program to get square root of a number

devquora
devquora

Posted On: Jan 27, 2023

C program to get square root of a number

 

Overview:

In this article, I want to introduce you with number and its digits. Then I will demonstrate how to find square root of the number with the Logic to find sqrt of a number. After all, I will write c program to get square root of a number. After all, I will show Program output.

Table of contents:

  1. What is Number?
  2. What is Square root of a Number?
  3. Demonstration How to find square root of the number?
  4. Logic to find square root of a number
  5. C program to get square root of a number
  6. Conclusion

What is Number?

Number is an arithmetical value, expressed by a word, symbol, or figure, representing a particular quantity and used in counting and making calculations. For example, 1243 has 4 symbols so we can say that 1243 is 4 digits number.

What is Square root of a Number?

square root can be defined as A square root of a number is a value that, when multiplied by itself, gives the number. Square root of a number is denoted by √ number. For example,

√ 81 = 9.

√ 16 = 4.

√ 25 = 5.

Demonstration How to find the square root of the number?

Demo of Reverse Number

Logic to find the square root of a number

A c programming language provides us a platform to use various approaches to find out the square root of any number. We can either draft our own code or can use the predefined function in. C to find out the square root. Below is the code that can be used to get the square using a simple mathematical expression. Using the below method will help in getting the square root integer value. For instance, if the square root of any value is 4.965. Like the square root of 25 is 5 and the below code will work accurately in order to calculate the square root of such number.

To get sum of each digit by c program, use the following logic:

    • Step 1: Define a user-defined function findSQRT(double N).
    • Step 2: find the square root of the any by using the predefined function sqrt()
    • Step 3: Call this user-defined function within the main() function.

C program to get the square root of a number

#include <stdio.h>
#include <math.h>
 
// Function to find the square-root of N
double findSQRT(double N)
{
    return sqrt(N);
}
 
int main()
{
    int number ;
    printf("Please! Enter any integer: ");
	scanf("%d", &number); 
    // Function call
    printf("%f ", findSQRT(number));
    return 0;
} 

Demo of Reverse Number

Conclusion:

A number is an arithmetical value, expressed by a word, symbol, or figure, representing a particular quantity and used in counting and making calculations. This program allows the user to enter any number and then finds the square root of that number using the math function sqrt () This program uses the math function findSQRT(int number) to find the square root of a number. As we all know √number = number½.

    Please Login or Register to leave a response.

    Related Articles

    C Program Examples

    C Program to convert Decimal to Binary Number

    A Decimal Number is constructed with any digit from 0 to 9. For instance, 24 is a Decimal Number constructed from the digits 2 and 4. A Binary Number is constructed with digits 0 and 1. For instance, ..

    C Program Examples

    C program to reverse a string

    This program reversed the entered string that means opposite of the previous string sequence...

    C Program Examples

    C program to reverse an Integer number

    Are you want a demonstration of The C Program that reverses an Integer number? This Program reversing the sequence of digits in an Integer. After the successful compilation of the program, a message..