# C PROGRAMS
C Basics
➤ Introduction to C
➤ Compile and Execute
➤ Hello, World! in C
➤ Identifiers & Keywords
➤ Data types in C
➤ Variables in C
➤ Comments in C
➤ Operators in C
➤ Bitwise Operators
➤ Printf() in C
➤ Input using scanf()
C Basic Programs
➤ Size & Range of Data Types
➤ C Programs for Beginners
➤ Add Subtract Multiply & divide
➤ Sum & Average of 3 Numbers
➤ Simple and Compound Interest
➤ Distance between two Points
➤ Find Circle Triangle Area
➤ ASCII Value of Character
➤ Find Square root of Number
➤ Different Swapping Programs
Program description:- Write a C program to find the square root of a given number.
A square root of a number is a value that, when multiplied by itself, gives the number. Example: 4 × 4 = 16, so a square root of 16 is 4. Note that (−4) × (−4) = 16 too, so −4 is also a square root of 16. The symbol is √ which always means the positive square root.
Program to find Square Root of a Number in C
#include<stdio.h>
#include<math.h>
int main()
{
int number;
double result;
printf("Enter any integer number: ");
scanf("%d",&number);
result = sqrt(number);
printf("Square root value=%.2lf",result);
return 0;
}
Output:-
Enter any integer number: 25
Square root value=5.00
Enter any integer number: 30
Square root value=5.48
The sqrt() function is defined in C language to calculate the square root value of a number. It is defined inside “math.h” header file.
Note:- If you are using Linux/Unix and getting error undefined reference to 'sqrt'
then see this undefined reference to ‘sqrt’ even included math.h header file.
To find square root of a number without using sqrt() function see here.
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!
Similar Basic C programming examples
- Hello, World! Program in C
- Find the size & range of Data Types
- Simple C Programs for Beginners
- Sum & Average of 3 Numbers in C
- Compute simple & compound Interest
- Distance between two points using C
- Area of a Circle Triangle and Rectangle
- Display ASCII value of a character
- Find the sum of elements in an array
- Display even & odd numbers in an array
- Sum & count of even-odd in array
- Count the positive, negative, and zeros in an array
- Sum of +ve & -ve numbers in array
- Average & numbers greater than average in array
- Smallest & largest array element
- First & Second max and min number
- C program to sort a list of an array
- Search an Array element
- Search position of Nth times occurred element in array
- C program to insert an element
- C program to delete an element
Thank you so much sir/madam this web site, more useful to me, and thank you.