Function with argument but no return value in C programming language | Coding classpoint

Function with argument but no return value



Here the function have argument so the calling function send data to the called function but called function dose n’t return value.

There could be occasions where we may need to design functions that may not take any arguments but returns a value to the calling function. A example for this is getchar function it has no parameters but it returns an integer an integer type data that represents a character.

Syntax: 

void fun (int,int); 
 main() 
 {
 int (a,b);
 }
 void fun(int x, int y); 
 { 
 Statement; 
 } 

Example:

#include <math.h>  
#include <stdio.h>     
int sum(); 
 int main()  
{      
int num;      
num = sum();      
printf(" Sum of two given values = %d", num);      
return 0; 
 }     
int sum()  
{     
 int a = 50, b = 80, sum;      
sum = sqrt(a) + sqrt(b);     
return sum; 
 } 

Output:

Sum of two given values = 16
Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.