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 function
  fun1();
  
  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语言 函数的参数传递示例

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值