sqrt C code example

Example 1: root in C

#include <stdio.h>
#include <math.h>

int main()
{
    double num = 6, squareRoot;

    squareRoot =  sqrt(num);
    printf("Square root of %lf =  %lf", num, squareRoot);

    return 0;
}

Example 2: sqrt in c

#include <math.h>
double sqrt(double arg);

Example 3: c sqrt

double sqrt(double arg);

Example 4: square in c

#include <math.h>
int main()
{
	float number;
  	square = pow(number,2); //This returns number raised to the power 2
  	printf("The square of %f is %f", number, square);
  	return 0;
}

Example 5: square in c

#include <stdio.h>
int main()
{
	float number;
	printf("Enter a number: ");
	scanf("%f", &number);
	square = number * number;
	printf("square of the given number %f is %f", number, square);
	return 0;
}

Tags:

C Example