Friday 7 December 2012

Mathematical functions in C language


Q) Which statement will you add in the following program to work it correctly?

#include<stdio.h>
int main()
{
    printf("%f\n", log(36.0));
    return 0;
}

A. #include<conio.h> B. #include<math.h>
C. #include<stdlib.h> D. #include<dos.h>

Explanation:



math.h is a header file in the standard library of C programming language designed for basic mathematical operations. Whenever Mathematical operation is to be performed then math.h is need to included to execute the program.

Declaration syntax: double log(double);

which means it accepts double type variable as input and return double type result. In the above program it takes 36.0 as input which is double and it will return double data.



No comments:

Post a Comment

Best geography books for UPSC prelims, mains

This post is intended to clear the confusion that prevails among the aspirants over how to prepare for UPSC geography and the best books f...