
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
C function argument and return values
Here we will see what are the different types of C functions based on the return values and arguments.
So a function either can take some arguments, or nothing is taken. Similarly, a function can return something, otherwise does not return anything. So we can categorize them into four types.
- Function with No argument and No return type.
- Function with No argument and Return something.
- A function that takes argument but returns nothing.
- Functions that take an argument and also return something.
Example
#include <stdio.h> void my_function() { printf("This is a function that takes no argument, and returns nothing."); } main() { my_function(); }
Output
This is a function that takes no argument, and returns nothing.
Here this function is not taking any input argument, and also the return type is void. So this returns nothing.
Example
#include <stdio.h> int my_function() { printf("This function takes no argument, But returns 50
"); return 50; } main() { int x; x = my_function(); printf("Returned Value: %d", x); }
Output
This function takes no argument, But returns 50 Returned Value: 50
Here this function is not taking any input argument, but its return type is int. So this returns a value.
Example
#include <stdio.h> void my_function(int x) { printf("This function is taking %d as argument, but returns nothing", x); return 50; } main() { int x; x = 10; my_function(x); }
Output
This function is taking 10 as argument, but returns nothing
Here this function is taking an input argument, but its return type is void. So this returns nothing.
Example
#include <stdio.h> int my_function(int x) { printf("This will take an argument, and will return its squared value
"); return x * x; } main() { int x, res; x = 12; res = my_function(12); printf("Returned Value: %d", res); }
Output
This function is taking 10 as argument, but returns nothing
Here this function is taking any input argument, and also returns value.
- Related Articles
- C++ Program to create a function without argument and without a return value
- Golang Program to Create a Function without Argument and Without a Return Value
- Haskell Program to create a function without argument and without a return value
- Haskell Program to create a function without argument but return a value
- How can we return multiple values from a function in C/C++?
- How to create a Function without Argument but return a value in Golang?
- How can we return multiple values from a function in C#?
- Information regarding function used in remote machine and their return values.
- Function overloading and return type in C++
- Return values of printf() and scanf() in C
- Haskell Program to return multiple values from the function
- How to return multiple values from the function in Golang?
- How to pass Python function as a function argument?
- Return the angle of the complex argument in Python
- Return the imaginary part of the complex argument in Python

Advertisements