function in C

log function in C programming language

log function in C programming language

In this tutorial, we will discuss log function in the C programming language

Description

In the C programming language, the log() Arithmetic function returns the logarithm of x to the based of e

log(): In C programming Language,log()  is used to perform  calculate natural logarithm of significant value

Declaration

The Syntax of the log()  in C Programming language

double log(double x);

Parameters or Arguments

X is the parameter or argument of this function which is used in the calculation of the logarithm of x to the base of e

Returns

The log function returns the logarithm of x to the base of e

Required Header

In this Language, the required header file for log()  is

#include<math.h>

log function in C

Example

The following example shows the usage of the log()

Program 1

 

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

int main()
{
    double a=1.5,b=1.25;
    printf("log value of %f is: %f\n",a,log(a));
    printf("log value of %f is: %f\n",b,log(b));
    getch();
    return 0;
}

 

When above program me  is compiled it will produce the following result

log value of 1.500000 is: 0.405465

log value of 1.250000 is: 0.223144

 

program 2

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

int main()
{   //define the variable
    double logValue;
    double inputValue;
    //get input from user
    printf("Please enter the value to calculate log value :");
    scanf("%lf",&inputValue);
    //calculate the log value
    logValue=log(inputValue);
    //display the log value
     printf("\nlog value of %lf is %lf\n",inputValue,logValue);
    getch();
    return 0;
}

When above program me  is compiled it will produce the following result

please enter the value to calculate log value :1.5
log value of 1.500000 is 0.405465

 

Other C programming language functions that are  similar to the cosine function      

cosh function   in C  language                               

sinh function in C language

tanh function in C language

abs function in C language

floor function in C language

ceil function in C language

round function in C language

sqrt function in C language

pow function in C language

exp function in C language

trunc function in C language

 

 

suggested for you

Function in C language

User defined function in C language

Arithmetic functions in C Language

String function in C language

log10 Arithmetic function in C Language
String function in C programming Language
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

Python code to Calculate sum of odd and even in a list

Python code to Calculate sum of odd and even in a list In this tutorial,…

3 days ago

How to find reverse number using method in Java

How to find reverse number using method In this article, we will discuss the concept…

6 days ago

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

4 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago