C program to find square root of a number
Write a C program to input any number from user and find square root of the given number.
Example:
Input number: 4
Output: 2
Input number: 4
Output: 2
Required knowledge:
Fundamentals of C, Data types, Taking user input in C
Program:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| /************************************************ * C program to find square root of a number * ************************************************/#include <stdio.h>#include <math.h>
void
main(){ double num, root; // Reads the number to find square root printf("Enter any number to find square root: "); scanf("%lf", &num); //Calculates square root of num root = sqrt(num); printf("Square root of %.2lf = %.2lf", num, root);}
|
Enjoy it..............

Comments
Post a Comment
Dears! Yours Comment approved in 24 hours also your answer in 24 hours.......