A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C - User define function example with no argument and no return type
Q:

C - User define function example with no argument and no return type

0

C - User define function example with no argument and no return type

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

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).

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program

/*  
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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now