
函数大致分为两类,如下: -
这些函数已在系统库中定义。
但是要使用库函数,用户必须了解函数的语法。
示例 -
立即学习“C语言免费学习笔记(深入)”;
y= sqrt (x) x number must be positive eg: y = sqrt (25) then ‘y’ = 5
下面给出的是预定义函数 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 25 Squareroot = 5
考虑一些更预定义的函数 -
以下是使用预定义函数的 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 2 cuberoot = 2 exponent value = 8103 logarithmic value = 2 ceil value = 9 power = 81
以上就是C语言中的预定义函数有哪些?的详细内容,更多请关注php中文网其它相关文章!
C语言怎么学习?C语言怎么入门?C语言在哪学?C语言怎么学才快?不用担心,这里为大家提供了C语言速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号