#include <stdio.h>
int main() {
printf("Number = %.4f", sqrt(14.23)); // Number = 3.7723
printf("\nNumber = %.4f", sqrt(4.831)); // Number = 2.1980
printf("\nNumber = %.4f", sqrt(-17.831)); // Number = -nan
printf("\nNumber = %.4f", sqrt(-22.23)); // Number = -nan
return 0;
}
We will get Square root of a given number by using sqrt() function. We can format the out put by using printf().
#include <stdio.h>
#include <math.h>
int main(void){
float num; // num is declared as float variable
num=225; // data is stored
printf("num = %.4f", sqrt(num)); // final output
return 0;
}
The above code will give this output.
num = 15.0000
Example integer output
#include
#include
int main(void){
int num; // num is declared as integer variable
num=sqrt(625); // data is stored
printf("num = %d", num); // final output
return 0;
}