Tagged: c language declare function

Function declaration and Prototype in C Programming Language 19

Function declaration and Prototype in C Programming Language

By default, any C function returns an int value. If we want that the function should return a value other than int then we need to explicitly mention it in the function definition. Let us understand this using an example. Example 1: float fnGetAverage(int, int); //function prototype void main() { int x,y; float z; printf(“\nEnter the values for x and y\n”); scanf(“%d %d”, &x, &y); z = fnGetAverage(x,y); //function call printf(“\nThe average is %f”, z); } float fnGetAverage(int a, int b) { //function definition float c; c = (a+b)/2; //calculating average return c; //returning the value } Output: Enter the...

FREE C Cheatsheet - Speed Up Your C Programming.

FREE C Cheatsheet - Speed Up Your C Programming.

Download a 7-page free cheat sheet for easy and quick access to C Concepts, Snippets, and Syntax.

Thank you! Check you inbox and access your cheat-sheet