Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs

C log Function

by suresh

The C log function is one of the C Math Functions, used to calculate the logarithmic value of the given number with base E. The syntax of the log in C Programming is

double log(double number);

C log Function Example

The C math logarithmic Function allows you to find the logarithmic value of base E.

In this program, We are going to find the logarithmic value of different values, and display the output.

/* LOG in C Programming Example */

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

int main()
{
    printf("\n The Logarithmic Value of 0       = %.4f ", log(0));
    printf("\n The Logarithmic Value of 1       = %.4f ", log(1));
    
    printf("\n The Logarithmic Value of 5       = %.4f ", log(5));
    printf("\n The Logarithmic Value of 16.4    = %.4f ", log(16.4));
    
    printf("\n The Logarithmic Value of -9.32   = %.4f ", log(-9.32));  
    printf("\n The Logarithmic Value of -15.34  = %.4f ", log(-15.34));
  
    return 0;
}

OUTPUT

C log Function 1

C log Example 2

In this C Programming example, we are allowing the user to enter their own value. Next, we used the log function to find the logarithmic value of the user-given number with base E.

/* LOG in C Programming Example */

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

int main()
{
    float number, logValue;

    printf(" Please Enter any Numeric Value :  ");
    scanf("%f", &number);
  
    logValue = log(number);
  
    printf("\n Logarithmic Value of %.2f = %.4f ", number, logValue);
  
    return 0;
}

OUTPUT

C log Function 2

Placed Under: C Programming

  • C Comments
  • C Escape Sequence
  • C Programming Operators
  • C Arithmetic Operators
  • C Assignment Operators
  • C Bitwise Operators
  • C Conditional Operator
  • C Increment & Decrement Optr
  • C Logical Operators
  • C Relational Operators
  • C Sizeof Operator
  • C If Statement
  • C IF ELSE Statement
  • C Else If Statement
  • C Nested If
  • C Break Statement
  • C Continue Statement
  • C Goto Statement
  • C Switch Case
  • C For Loop
  • C While Loop
  • C Do While Loop
  • C Arrays
  • C Two Dimensional Array
  • C Multi Dimensional Array
  • C String
  • C Structures
  • C Nested Structures
  • C Array of Structures
  • C Structures and Functions
  • C Union
  • C Structure & Union differences
  • C Pointers
  • C Pass Pointers to Functions
  • C GETS
  • C fgets Function
  • C fgetc
  • C fputs function
  • C fputc
  • C Functions
  • C Types of Functions
  • C Pass Array to Functions
  • Call By Value & Call By Reference
  • C Recursion
  • C Program Examples
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy