×

C Programs

C Basic & Conditional Programs

C Looping Programs

C String Programs

C Miscellaneous Programs

C - User-defined function example with arguments and no return type

User define function example with arguments and no return type - In this C program, we are defining a function that will not return any value but have arguments.
Submitted by IncludeHelp, on April 18, 2018

C program for user-defined function example with arguments and no return type

Here, we are function fun1 which has two arguments int and char*, while calling the function, we are passing two values, integer value and character array.

Consider the program, how can we declare and define a function that can use integer and character pointer arguments.

Source Code

/*  
C - User define function example with arguments 
and no return type
*/

#include <stdio.h>

// function with void return type
void * fun1(int sum , char *str)
{
  printf("\nThe value of sum is : %d",sum);
  
  printf("\nThe string is : "); 
  puts(str);
}

// main function
int main()
{
  int a=10;
  char buffer[30]="includehelp.com";
  
  //Calling function 
  fun1(a,buffer);
  
  return 0;
}

Output

The value of sum is : 10
The string is : includehelp.com

C User-defined Functions Programs »

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.