当前位置:网站首页>Method of C language self defining function
Method of C language self defining function
2022-07-02 16:56:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
One 、C Call of custom function of language
1. Declare a custom function :
void fun(void);// Declaration of functions
You can also write custom functions before the main function ;
2. Call the user-defined function in the main function :
int main(void)
{
fun();// call fun function ;
return 0;
}
3. The function of writing custom functions :
void fun(void)
{
int a=12;
printf(“a=%d”,a); Output a
}
The source code is as follows :
#include "stdio.h"
void fun(void);// Declare custom functions
int main(void)// The main function {fun();// call fun function “
return 0;}
void fun(void){int a=12;// Define an integer constant a=12;printf("a=%d",a);// Output a;}
shipment Line program results :
a=12
Two 、 Functions with parameters
1, Declare a custom function :
void fun(uchar a);
2, Call function
int main(void)// The main function { int i; for(i=0;i<8;i++) { fun(i);// call fun function There must be parameters in brackets , Otherwise, an error will be reported printf(“\n”);// Line break }
return 0;}
3. Write custom functions
void fun(char a)// fun The function takes a char Parameters of type { int i=0; char b=’*’; for(i=8;i>0;i–) printf(“%c”,b);// Output a; }
Source program :
#include "stdio.h"
void fun(char a);// Declare custom functions
int main(void)// The main function {int i;for(i=0;i<8;i++){fun(i);// call fun function printf("\n");// Line break }
return 0;}
void fun(char a){int i=0;char b='*';for(i=8;i>0;i--)printf("%c",b);// Output a;}
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/147813.html Link to the original text :https://javaforall.cn
边栏推荐
- C语言自定义函数的方法
- [cloud native] briefly talk about the understanding of flume, a massive data collection component
- Yyds dry inventory uses thread safe two-way linked list to realize simple LRU cache simulation
- Interview summary of large factories
- PCL least median square method fitting plane
- 学习周刊-总第60期-2022年第25周
- PCL 点云镜像变换
- 2322. 从树中删除边的最小分数(异或和&模拟)
- Student course selection system (curriculum design of Shandong Agricultural University)
- MOSFET器件手册关键参数解读
猜你喜欢
![[North Asia data recovery] data recovery case of raid crash caused by hard disk disconnection during data synchronization of hot spare disk of RAID5 disk array](/img/51/f9c1eed37794db8c8d0eefd60b9e3d.jpg)
[North Asia data recovery] data recovery case of raid crash caused by hard disk disconnection during data synchronization of hot spare disk of RAID5 disk array

基于多元时间序列对高考预测分析案例

基于Impala的高性能数仓实践之执行引擎模块

Trigger: MySQL implements adding or deleting a piece of data in one table and adding another table at the same time

串口控制舵机转动

电脑自带软件使图片底色变为透明(抠图白底)

What if the win11 app store cannot load the page? Win11 store cannot load page

Take you ten days to easily complete the go micro service series (I)

linux下配置Mysql授权某个用户远程访问,不受ip限制

pwm呼吸燈
随机推荐
sql解决连续登录问题变形-节假日过滤
Unity Json 编写
What is normal distribution? What is the 28 law?
SSM integration exception handler and project exception handling scheme
Global and Chinese market of switching valves 2022-2028: Research Report on technology, participants, trends, market size and share
2322. 从树中删除边的最小分数(异或和&模拟)
Multi task prompt learning: how to train a large language model?
L'explosion de John utilise l'encodage d'entrée par défaut: UTF - 8 Loaded 1 password Hash (bcrypt [blowfish 32 / 64 X3])
什么是泛型?- 泛型入门篇
LeetCode 1. Sum of two numbers
pwm呼吸燈
流批一体在京东的探索与实践
ROW_NUMBER()、RANK()、DENSE_RANK区别
Leetcode1380: lucky numbers in matrix
Bib | graph representation based on heterogeneous information network learning to predict drug disease association
Where can I open computer administrator permissions
Student course selection system (curriculum design of Shandong Agricultural University)
Machine learning perceptron model
Talk about an experience of job hopping and being rejected
Seal Library - installation and introduction