您好,欢迎访问一九零五行业门户网

C语言中的预定义函数有哪些?

函数大致分为两类,如下: -
预定义函数用户定义函数预定义(或)库函数这些函数已在系统库中定义。
程序员将重用系统库中已有的代码来编写无错误的代码。但是要使用库函数,用户必须了解函数的语法。
示例 -
sqrt() 函数在 math.h 库中可用它的用法是 -y= sqrt (x)x number must be positiveeg: y = sqrt (25)then ‘y’ = 5
printf ( ) 存在于 stdio.h 库中。clrscr ( ) 存在于 conio.h 库中。示例下面给出的是预定义函数 sqrt、printf、conio 的 c 程序 -
#include<stdio.h>#include<conio.h>#include<math.h>main ( ){ int x,y; clrscr ( ); printf ("enter a positive number"); scanf (" %d", &x) y = sqrt(x); printf("squareroot = %d", y); getch();}
输出您将看到以下输出 -
enter a positive number 25squareroot = 5
考虑一些更预定义的函数 -
cbrt(x):x 的立方根log(x):x 底的自然对数eceils(x):将x四舍五入为不小于x的较小整数pow(x,y):x的y次方……...pow(x,y):x的y次幂…… ul>示例以下是使用预定义函数的 c 程序 -
#include<stdio.h>#include<math.h>main ( ){ int x,y,z,n,k,p,r,q; printf ("enter x and n values:"); scanf (" %d%d", &x,&y) y=cbrt(x); z=exp(x); k=log(x); p=ceil(x); q=pow(x,r); printf("cuberoot = %d", y); printf("exponent value = %d",z); printf("logarithmic value = %d", k); printf("ceil value = %d", p); printf("power = %d", q); getch();}
输出输出如下 -
enter x and n values:9 2cuberoot = 2exponent value = 8103logarithmic value = 2ceil value = 9power = 81
以上就是c语言中的预定义函数有哪些?的详细内容。
其它类似信息

推荐信息