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语言 函数的参数传递示例