Square Root of a Number

Spread the love

Problem Statement

Given a number n, devise an algorithm to compute its square root.

Code

// Square root of a number upto 2 decimal places
#include <stdio.h>
#include <math.h>
int main()
{
int a;
printf("Enter the numbers do you want square root:");
scanf("%d",&a);
while(a--){
long b;
printf("Enter the numbers: \n");
scanf("%ld",&b);
float r= sqrt(b);
printf("%.2f\n",r);
   }
/* Tech - https://tech.arclasses.net */
return 0;
}

Sample Input

6
36
16
9
20
1
11 

Sample Output

6.00
4.00
3.00
4.47
1.00
3.32

Read more…


Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *