作业帮 > 综合 > 作业

c语言编程n次方怎么表示

来源:学生作业帮 编辑:灵鹊做题网作业帮 分类:综合作业 时间:2024/04/19 19:58:48
c语言编程n次方怎么表示
c语言编程n次方怎么表示
C语言中的数学函数:pow
  原型:在TC2.0中原型为extern float pow(float x, float y); ,而在VC6.0中原型为double pow( double x, double y );
  头文件:math.h
  功能:计算x的y次幂.
  返回值:x应大于零,返回幂指数的结果.
  举例1:(在VC6.0中运行通过)
  #include
  #include
  int main(void)
  {
  double x = 2.0, y = 3.0;
  printf("%lf raised to %lf is %lf\n", x, y, pow(x, y));
  return 0;
  }
  举例2: (在TC2.0中运行通过)
  // pow.c
  #include
  #include
  main()
  {
  clrscr(); // clear screen
  textmode(0x00); // 6 lines per LCD screen
  printf("4^5=%f",pow(4.,5.));
  getchar();
  return 0;
  }