How to call function in C?

Simple:

func();

If you have ever used printf() or any other standard library calls, you have made a function call. These functions are not part of the language; they are part of the library, which is something completely different. Just because they are standard does not mean they are part of the core language.

Similarly, if you have written a C program at all, you know how to write a new function. The main() function may be a special case, but the syntax is the same as it is for any other function:

return_type func()
{
    /* function body */
    return return_value;
}

If there is no return value, the type would be void, and you would omit the return statement. If you need to pass parameters to the function, you would declare them in the parameter list:

double foo(int bar, double baz)
{
    return bar / baz;
}

Many new programmers get confused by this, which is natural, but the answers are quite simple, really.

If you are going through the sample program, you can understand how to call a function depending upon the type of parameter passed and value returned. in the program you can see the function call c = sum(a,b);

#include<stdio.h>
#include<conio.h>

int sum(int,int); 

void main() 
{
int a,b,c; 
printf("\nEnter the two numbers : ");
scanf("%d%d",&a,&b);

c = sum(a,b); //function call

printf("\nAddition of two number is : %d",c); 
getch(); 
}

int sum (int num1,int num2) //function
{ 
int num3; 
num3 = num1 + num2 ; 

return(num3); 
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.