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 function int main() {//calling the functionfun1();return 0; }Output
輸出量
The sum of all array elements is : 21翻譯自: https://www.includehelp.com/c-programs/user-define-function-example-with-no-argument-and-no-return-type.aspx
c語言 函數的參數傳遞示例
總結
以上是生活随笔為你收集整理的c语言 函数的参数传递示例_C-用户定义的函数示例,没有参数,没有返回类型...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 回溯算法解决八皇后_4皇后问题和使用回溯
- 下一篇: c语言定义5个元素数组, 对数组进行从小