How to Create and Use FUNCTION in C Language

Create and Use FUNCTION in C Language:

(1) FUNCTION is a set of code that runs when it is called. In this blog, we will see how to create and called FUNCTION in C language.

(2) Advantage of creating FUNCTION is that they are reused. Means defining the code once and using FUNCTION many times.

(3) In C Language, there are Predefined functions such as MAIN(), PRINTF(), SCANF().

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

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

(3) 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

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

run the code using the function

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

Output obtain from switch statement in C

Use of ASCII function in SQL
Use of CONCAT_WS Function in SQL
DATALENGTH (Transact-SQL)– Microsoft Docs
How to Create New Database in Microsoft SQL Server

Leave a Reply