1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > c语言 函数的参数传递示例_C-用户定义的函数示例 没有参数 没有返回类型...

c语言 函数的参数传递示例_C-用户定义的函数示例 没有参数 没有返回类型...

时间:2019-03-17 01:16:20

相关推荐

c语言 函数的参数传递示例_C-用户定义的函数示例 没有参数 没有返回类型...

c语言 函数的参数传递示例

Define a function with no argument and no return type in C language.

用C语言定义一个没有参数且没有返回类型的函数。

In the program, we have function named fun1 which has no argument and no return type (void is the return type - that means, function will not return anything).

在程序中,我们有一个名为fun1的函数,它没有参数,也没有返回类型( void是返回类型-这意味着该函数将不返回任何内容)。

Within the function fun1 we are declaring an array, calculating sum of its elements and printing the sum.

在fun1函数中,我们声明一个数组,计算其元素的总和并打印总和。

程序 (Program)

</ s> </ s> </ s>

/* User define function example with no argument and no return type */#include <stdio.h>void fun1(void){int array[10]={1,2,3,4,5,6};int i=0,sum=0;for(i=0;i<6;i++){sum = sum + array[i];}printf("\nThe sum of all array elements is : %d",sum);}// main functionint main(){//calling the functionfun1();return 0;}

Output

输出量

The sum of all array elements is : 21

翻译自: /c-programs/user-define-function-example-with-no-argument-and-no-return-type.aspx

c语言 函数的参数传递示例

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。