country
$20 Bonus + 25% OFF
Securing Higher Grades Costing Your Pocket? Book Your Assignment at The Lowest Price Now!
Add File

Error goes here

Definition of Parameters

Referencing Styles : Harvard | Pages : 1

Definition of parameters

A parameter, also known as formal argument, is used in computer programming. A parameter is a special type of variable that is used within a subroutine in order to refer to any one of the data that is being provided as an input in the subroutine. In the arguments, also known as actual argument or actual parameters, these data are considered as the values and, are used to call a subroutine. Usually, in the definition of a subroutine, an ordered list of parameters are included and every time a subroutine is called, the argument are evaluated for that specific call, and after that the results are assigned to the parameters.

Arguments in the context of computer science, is the actual input that is passed to a function, or a procedure, or to a routine in a call statement. Parameters are basically the variables that are present within the subroutine. An example can be considered as: if the add subroutine is defined as def add (a, b); return (a + b), in this example, a and b are the parameters. In the contrary, if the subroutine is called as add (3, 4), then the arguments are 3 and 4. In this context of calling the arguments, if the subroutine is again called as x = 4 and y = 5; add (x, y), then in that case the variables x and y are known as the arguments and not the values 4 and 5.

There are mainly, two types of parameter passing methods in a function in C programming language. The two types are: Call by Value and another is Call by Reference. When the parameters are passed to a function it is known as actual parameters, and when the function receive a parameter it is known as formal parameters.

In call by value parameter passing method, the values of the actual parameters are copied into the formal parameters of the function and these two different parameters are stored in different memory locations. The actual parameters remain unaffected with any changes in the function. On the other hand, in call by references parameters passing method both the actual and formal parameters are stored in the same memory location. So, in this case, the actual parameters will reflect any changes made within a function.

Example of Call by Value:

#include <stdio.h>

// Prototype of the function

void swap (int x, int y);

// Main function

int main()

{

    int a = 5, b = 10;

    // Passing the Values

    swap (a, b);

    printf ("a=%d, b=%d\n", a, b);

    return 0;

}

// This is the swap function  to swap the values

  void swap (int x, int y)

{

    int temp;

    temp = x;

    x = y;

    y = temp;

    printf ("x=%d, y=%d\n", x, y);

}

Output:

x=10, y=5

a=5, b=10

Example of Call by Reference:

#include <stdio.h>  

// Prototype of the function

void swap (int*, int*);

// Main function

int main()

{

    int a = 5, b = 10;

    // Passing the references

    swap (&a, &b);

    printf ("a=%d, b=%d\n", a, b);

    return 0;

}

// This is the function that swaps the two variables

void swap (int* x, int* y)

{

    int temp;

    temp = *x;

    *x = *y;

    *y = temp;

    printf("x=%d, y=%d\n", *x, *y);

}

Output:

x=10, y=5

a=10, b=5

Definition of function

In computer programming language, a unit of code that is being defined within a larger amount of code structure is commonly known as function. Generally, the unit of code is capable of working with different inputs and variables by producing a concrete result that involve changes to a variable or the actual operation, which are based on the input. A function, that is present within a bigger structure of code, is also referred to as a procedure or subroutine. Whenever a function or subroutine is called by the code the function is operated on the inputs to produce the effective results. The basic structure of any function in C programming language is:

return_type function_name (list of the parameters){

body of the function

return [expression];

}

The return_type defines the data type of the value that the function will return. There are some functions that do not return any vale and have a void data type.

The function_name is the name of the function. The function signature comprises of the list of parameters and the function name together.

List of parameters will contain all the values that are passed to the function. These values are referred to as actual parameters or arguments. The list of parameters refers to the type of the parameters, order and the number of parameters that will be used in the function. Moreover, parameters are optional. So, a function may or may not contain parameters.

Body of the function defines the working of the function and comprises of a number of statements.

An example of a C programming function:

#include <stdio.h>

int add(int a, int b)

{

     int sum;

     sum = a + b;

     return sum;

}

int main()

{

     int variable1, variable2;

     printf ("Enter the first number: ");

     scanf ("%d", &variable1);

     printf ("Enter the second number: ");

     scanf ("%d",&variable2);

     int result = add (variable1, variable2);

     printf ("Output: %d", result);

     return 0;

}

Example of C user defined function:

// multiplication of two numbers

#include <stdio.h>

int multiply (int a, int b);         // prototype of the function

int main()

{

  int num1, num2, result;

  printf ("Enters two numbers: ");

  scanf ("%d %d", &num1, &num2);

  result = multiply (num1, num2);        // calling the function

 printf("Result = %d", result);

   return 0;

}

int multiply (int a, int b)         // definition of the function

{

    int res;

    res = a*b;

    return res;                  // returning the result

}

Output:

The output depends on the input of the user. If the user gives the input as:

Enter two numbers: 4 5

Result = 20

In the above example the two variables num1 and num2 are passed during the calling of the function. In the function definition the parameters a and b accepts the arguments, which are the formal parameters, that have been passed in the function.  

Solutions

OR

MyAssignmenthelp.com offers best thesis writing service in USA. We offer the right platform for those who often search can anyone help me write a thesis perfectly. With a pool of qualified and experienced online thesis makers, we provide highest quality PHD thesis writing services to students in USA. Our PhD thesis help services include writing help, help with selecting topics, assistance for researching and editing and proofreading help.

Save Time & improve Grade

Just share requirement and get customized Solution.

watch
question
We will use e-mail only for:

arrow Communication regarding your orders

arrow To send you invoices, and other billing info

arrow To provide you with information of offers and other benefits

Add File

Error goes here

1,549,346

Orders

4.9/5

Overall Rating

5,109

Experts

Our Amazing Features

delivery

On Time Delivery

Our writers make sure that all orders are submitted, prior to the deadline.

work

Plagiarism Free Work

Using reliable plagiarism detection software, Turnitin.com.We only provide customized 100 percent original papers.

time

24 X 7 Live Help

Feel free to contact our assignment writing services any time via phone, email or live chat. If you are unable to calculate word count online, ask our customer executives.

subject

Services For All Subjects

Our writers can provide you professional writing assistance on any subject at any level.

price

Best Price Guarantee

Our best price guarantee ensures that the features we offer cannot be matched by any of the competitors.

Our Experts

Assignment writing guide
student rating student rating student rating student rating student rating 5/5

1692 Order Completed

98% Response Time

Alfred Dodd

PhD in Computer and Information Science with specialization in Database

Wellington, New Zealand

Hire Me
Assignment writing guide
student rating student rating student rating student rating student rating 5/5

529 Order Completed

95% Response Time

Ivan Blank

PhD in Functional Human Biology

Wellington, New Zealand

Hire Me
Assignment writing guide
student rating student rating student rating student rating student rating 5/5

1592 Order Completed

96% Response Time

Jane Sima

Ph.D in Psychology with Specialization in Industrial-Organizational Psychology

Singapore, Singapore

Hire Me
Assignment writing guide
student rating student rating student rating student rating student rating 5/5

234 Order Completed

100% Response Time

Samantha Ji

PhD in Chemistry with Specialization in Organic

Singapore, Singapore

Hire Me

FREE Tools

plagiarism

Plagiarism Checker

Get all your documents checked for plagiarism or duplicacy with us.

essay

Essay Typer

Get different kinds of essays typed in minutes with clicks.

edit

GPA Calculator

Calculate your semester grades and cumulative GPa with our GPA Calculator.

referencing

Chemical Equation Balancer

Balance any chemical equation in minutes just by entering the formula.

calculator

Word Counter & Page Calculator

Calculate the number of words and number of pages of all your academic documents.

Refer Just 5 Friends to Earn More than $2000

Check your estimated earning as per your ability

1

1

1

Your Approx Earning

Live Review

Our Mission Client Satisfaction

it was really good and i will recomend it to my friends. i got above average marks for it

flag

User Id: 439116 - 22 Jan 2021

Australia

student rating student rating student rating student rating student rating

Dear Sir/Madam, Thank you very much for your expertise and assistance. I was very informative and very helpful. Regards,

flag

User Id: 561159 - 22 Jan 2021

Australia

student rating student rating student rating student rating student rating

Dear Sir/Madam, Thank you very much for the excellent work! It really helped me a lot. Regards,

flag

User Id: 561159 - 22 Jan 2021

Australia

student rating student rating student rating student rating student rating

the best team ever and very timely manners with affordable pricing and won’t have any complaints

flag

User Id: 237518 - 22 Jan 2021

Australia

student rating student rating student rating student rating student rating
Definition of Parameters has been added in your library.
callback request mobile
Have any Query?