printf("output =%d \n ",sqrt(25)+10);
output is 0
and here also zero
printf("result %f \n",abs(-5.67)+15);
output is 0.000000
sqrt() returns a float you are trying to print it as an int
abs returns an int you are trying to print it as a float (double really due to default argument promotion)
#include
int main(void){
int x=180; double y;
printf("output =%d \n ",(int) sqrt(25)+10);
printf("output =%f \n ", sqrt(25)+10);
printf("result %d \n", abs((int)-5.67)+15);
return 0;
}
or you can
#include
for the prototype for abs()
the compiler does not know what arguments abs() takes
you are giving it a float so it assumes that is right
but abs() really takes an int --- oops.
so you can #include
add it yourself (not recommended)
int abs(int);
or cast the argument to int
abs((int) -5.7)
[ C does not have ANY "commands" - it has keywords, functions, labels, statements and expressions -- no "commands"]
int x=180; double y;
printf("output =%d \n ",sqrt(25)+10);
output is 0
and here also zero
printf("result %f \n",abs(-5.67)+15);
output is 0.000000