Computer Science, asked by Aapko3680, 1 year ago

Write the code to input a number and print the square root. Use the absolute value function to make sure that if the user enters a negative number, the program does not crash.
Example:
Enter a number: -16
Output:
4.0
help please

Answers

Answered by AmartyaChowdhury
55

Code in Python :-

num = float(input("Enter any number : "))

ab = abs(num)

sqrt = float(ab ** 0.5)

print(sqrt)

Answered by HanitaHImesh
5

Code in 'C' :

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

int main()

{

int a;

printf("Enter a number :") ;

scanf("%d", &a) ;

a=abs(a);

printf("The square root of a is %f",

sqrt(a));

return 0;

}

Similar questions