当前位置:网站首页>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
边栏推荐
- Shell脚本——Shell编程规范及变量
- PHP高效读大文件处理数据
- Perception of linear algebra 2
- SPC introduction
- Zhimeng dedecms security setup Guide
- PostgreSQL列存与行存
- ClickHouse-表引擎
- MySQL restores data through binlog file
- Aiot industrial technology panoramic structure - Digital Architecture Design (8)
- Smart doc + Torna generate interface document
猜你喜欢

JS, entries(), keys(), values(), some(), object Assign() traversal array usage

STM32__ 03 - beginner timer

基于51单片机红外无线通讯仿真

groutine

1-1 NodeJS

Lock锁

Devexpress GridView add select all columns

2.Electron之HelloWorld
![[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

Document operation II (5000 word summary)
随机推荐
Wiper component encapsulation
VLAN advanced technology, VLAN aggregation, super VLAN, sub VLAN
Shell-入门、变量、以及基本的语法
Deep understanding of control inversion and dependency injection
Further optimize Baidu map data visualization
TypeError: set_ figure_ params() got an unexpected keyword argument ‘figsize‘
Redis docker installation
CentOS MySQL multi instance deployment
Shell - introduction, variables, and basic syntax
Use of shell awk command
Self use learning notes - connected and non connected access to database
Self use learning notes - connectingstring configuration
Simulation of infrared wireless communication based on 51 single chip microcomputer
1-3 nodejs installation list configuration and project environment
Paging the list collection
Promise (I)
Go language, array, string, slice
Baidu Map Case - Zoom component, map scale component
Basic case of Baidu map
Clickhouse table engine