본문 바로가기
C 언어

C언어를 이용해서 Log 함수 계산하기

by treeCoder 2021. 1. 1.

C언어를 이용해서 Log 함수를 계산할 수 있다.

 

#include <stdio.h>

#include <math.h>

 

double logB(double x, double base) {

          return log(x)/log(base);

}

 

int main( ) {

          double a = logB(3.0, 2.0);

          double b = logB(5.0, 2.0);

 

          puts("log3/log2, log5/log2, log3/log2 * log5/log2 = ");

          printf("%lf %lf %lf", a, b, a * b);

          return 0;

}

 

댓글