C语言程序设计PPt第3章函数.pptVIP

  • 3
  • 0
  • 约6.52千字
  • 约 66页
  • 2017-04-20 发布于四川
  • 举报
C语言程序设计PPt第3章函数

第三章 函数;本章主要内容;函数的定义;函数的调用;例3-1编写一个求x的n次方的函数; 运行结果: 5 to the power 2 is 25;例3-2 数制转换;#include iostream.h double power (double x, int n); //声明函数原型power int main() { int i; int value = 0; char ch; cout Enter an 8 bit binary number ; for (i = 7; i = 0; i--) { cin ch; if (ch == 1) value += int(power(2,i)); //调用函数power } cout Decimal value is valueendl; } double power (double x, int n) //声明函数power { double val = 1.0; while (n--) val *= x; return(val); };例3-3编写程序求π的值;#includeiostream.h int main() { double a,b; double arctan(double x);//函数原型声明 a=16.0*arctan(1/5.0); b

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档