Create and Use Function with Parameters in C Language

Create and Use Function with Parameters in C:

(1) FUNCTION in C language is already explained in the blog “How to create and use Function in C Language”. In this blog, we will see how to pass parameters in the function to get results.

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

(3) Sample C language code and its output, as shown. In this example, we created a Function with one parameter.

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

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

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

run code for function parameters in C

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

Function Parameter Output in C Obtained

(7) Syntax:

  • Function with one parameter: MyFirstFunction(int x)
  • Function with more than one parameter: MyFirstFunction(int x,char a)

Continue Statement in C Language
Break Statement in C language
Assignment Operators in C Language
Sales Order Short Closed Feature in BC D365
Record.TransferFields(var Record [, Boolean]) Method– Microsoft Docs

Leave a Reply