C함수 제곱 계산 pow()
거듭제곱 값을 구합니다.
- 헤더: math.h
- 형태: double pow( double x, double y)
- 인수: double x 제곱 값을 구하려는 값
double y 지수 - 반환: double x의 y 제곱값을 반환
변수 타입별 함수 목록입니다.
변수 타입 | 함수 | 헤더 파일 |
double | pow( double x, double y) | math.h |
float | powf( double x, double y) | math.h |
long double | powl( double x, double y) | math.h |
C언어 pow() 함수 예제
#include <stdio.h>
#include <math.h>
int main( void)
{
double x = 2.2;
double y = 3.3;
printf( "x ^ y = %g\n", pow( x, y));
return 0;
}
C언어 pow() 예제 실행 결과
math.h를 사용했다면 컴파일할 때 반드시 -lm을 추가하세요.
]$ gcc test.c -lm
]$ ./a.out
x ^ y = 13.4895
]$
'컴퓨터 > 프로그래밍' 카테고리의 다른 글
C언어 제곱근 함수 sqrt() (0) | 2020.03.13 |
---|---|
C언어 난수 seed 지정 함수 srand() (0) | 2020.03.13 |
C언어 난수 함수 rand() (0) | 2020.03.13 |