Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c
math

What is log10 in C?

Sheza Munir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The log10 function allows users to calculate the common logarithmbase 10 of a number.

Library

The log10 function is accessible from the math.h library.

Syntax

double log10(double x)

Parameters

The function takes one parameter, a number for which a common logarithm is needed.

The number needs to be positive (greater than 0) as the logarithm of negative numbers, and zero, are undefined.

Return value

The log10 returns the common logarithm of the number given as a parameter. The returned number is of double the datatype.

Code

#include <stdio.h>
#include <math.h>
int main(){
double number, log_of_number;
number = 100;
log_of_number = log10(number); //taking the common log of number
printf("log10(%lf) = %lf\n", number, log_of_number);
// log10 of number will be printed
}

RELATED TAGS

c
math

CONTRIBUTOR

Sheza Munir
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring