Function Declaration in C Language

Function Declaration in C Language:

(1) In this blog we will see how to declare Function in C Language.

(2) It is recommended for optimizing the code. It should be advisable to write separate function definitions and function declarations.

(3) You can add as many parameters as you want.

(4) Sample C language code and its output, as shown:

#include <stdio.h>
#include <conio.h>
void  myfirstfunction(int x);// Declare function with parameter
intmain()
{
int x;
  x = 3;
myfirstfunction(x); //call the function by passing x parameter
getch();
return 0;
}
void  myfirstfunction(int x) // Creation of new function with parameter
{
switch(x)
    {
case 1:
printf(“LOW”);
break;
case 2:
printf(“Medium”);
break;
case 3:
printf(“High”);
break;
    }
}
Sample C language code for Function Declaration

(5) After that go to the “Build” menu and select the “Build” option for publishing the code as shown.

click on build for switch statement in codeblocks

(6) After building the code, press the “Run” button, as shown.

Run the C code for Function Declaration

(7) After pressing the “run” button, the output screen is opened, as shown.

Function Parameter Output in C Obtained

Create and Use Function with Parameters in C Language
Assignment Operators in C Language
DO WHILE Loop in C Language
Use of CONCAT Function in SQL
CONCAT_WS (Transact-SQL)– Microsoft Docs

Leave a Reply