当前位置:网站首页>C语言程序设计之函数的构造
C语言程序设计之函数的构造
2022-04-23 17:12:00 【wx625ea460982ad】
构造函数的目的:为了简化程序和使得你的程序更容易被他人理解
什么情况下推荐构造函数:当程序中的某一功能需要多次使用且实现的代码较长时,就推荐提前构造函数
怎么构造函数:简单来说,你想实现什么功能,就构造什么样的函数
比如:我想实现两个数的相加。程序如下:
#include<stdio.h>
int ADD (intx,inty)
{ int z=x+y;
return z;
}
int main()
{ int a=10;
int b=20;
int sum =0;
sum=ADD(a,b);
printf("%d\n",sum);
return 0;
|从这段程序中我们就可以看到,我想实现两个数的加减,那么我就在main函数之间提前定义一个ADD函数,让它的功能就是完成两个数的相加,然后在主程序中直接去调用这个函数就可以了。
版权声明
本文为[wx625ea460982ad]所创,转载请带上原文链接,感谢
https://blog.51cto.com/u_15607564/5248621
边栏推荐
- BUG_ me
- Promise (II)
- [logical fallacy in life] Scarecrow fallacy and inability to refute are not proof
- org. apache. parquet. schema. InvalidSchemaException: A group type can not be empty. Parquet does not su
- freeCodeCamp----shape_ Calculator exercise
- groutine
- Blue Bridge Cup provincial road 06 -- the second game of the 12th provincial competition
- 基于51单片机红外无线通讯仿真
- Webapi + form form upload file
- Nacos + aspnetcore + Ocelot actual combat code
猜你喜欢

How vscode compares the similarities and differences between two files

Lock lock

1-1 NodeJS

RPC核心概念理解

Go language, array, string, slice

2.Electron之HelloWorld

feign报400处理

On lambda powertools typescript

Smart doc + Torna generate interface document
![[registration] tf54: engineer growth map and excellent R & D organization building](/img/12/7aece45fbc9643c97cdda94b405118.jpg)
[registration] tf54: engineer growth map and excellent R & D organization building
随机推荐
Expression "func" tSource, object "to expression" func "tSource, object" []
Using quartz under. Net core -- preliminary understanding of [2] operations and triggers
How vscode compares the similarities and differences between two files
oracle 中快速获取表的列名列表
[C#] 彻底搞明白深拷贝
freeCodeCamp----prob_ Calculator exercise
[WPF binding 3] listview basic binding and data template binding
1-3 nodejs installation list configuration and project environment
Understanding of RPC core concepts
Self use learning notes - connectingstring configuration
MySQL modify master database
Nodejs reads the local JSON file through require. Unexpected token / in JSON at position appears
Summary of common websites
ASP. NET CORE3. 1. Solution to login failure after identity registers users
PHP efficiently reads large files and processes data
【题解】[SHOI2012] 随机树
STM32__ 03 - beginner timer
ASP. Net core dependency injection service life cycle
Scope and scope chain in JS
Grpc gateway based on Ocelot