Available 24 x 7 Assignment Help

With Tutoring

C Programming Help

Function With Arguments/Parameters/Variables

There are two ways of calling a Function in C.

  1. Call by value
  2. Call by reference

Call by value means, we give some values as arguments to a Function and it returns some value. Suppose we have made a program to add two numbers:

{`int add(int a, int b)
{ ;
//return a+b;

Now we call this Function in our main program,


where m and n are the two integers defined in our main Function.

What will happen here ?

The value of m and n will be copied in a and b and the Function will be executed. Hence after the execution of statement if you want to access the value m or n, it wont change, as the value has been copied.

This is the example of call by value. We can make this more clear by using swap Function:

Let us suppose that we have defined a Function swap which takes two integers as argument and swaps there values:

void swap(int a, int b)
printf(“\n The value of a is: %d”,a);
printf(“\n The value of b is: %d”,b);
int temp;
temp = a;
a = b;
b = temp;
printf(“\n The value of a is now: %d”,a);
printf(“\n The value of b is now: %d”,b);

Now we call this Function in our main program using:

int x,y;
x = 10;
y = 20;
printf(“\n The value of x is now: %d”,x);
printf(“\n The value of y is now: %d”,y);

Assignment Help With Function Calls

Tell me what do you expect the answer should be:

I think most of you must be thinking as we have swapped the values of x and y hence x should become 20 and y should be 10.

But CAREFUL !! You are making a mistake. As I told you when you call a function by value, the arguments are copied only. Hence the values of x and y wont change.

This is where comes the another part of game. “CALL OF FUNCTION BY REFERENCE”. We’ll discuss this in great detail when we’ll learn the chapter pointers.

In Call by reference, we give the address of the variables and the Function performs tasks directly on the variable and not on the copied values.

Topics in C Programming

24 x 7 Availability.
Trained and Certified Experts.
Deadline Guaranteed.
Plagiarism Free.
Privacy Guaranteed.
Free download.
Online help for all project.

Urgenthomework helped me with finance homework problems and taught math portion of my course as well. Initially, I used a tutor that taught me math course I felt that as if I was not getting the help I needed. With the help of Urgenthomework, I got precisely where I was weak:


  Urgent HomeWork

Disclaimer: The study tools and academic assistance/guidance through online tutoring sessions provided by Urgenthomework.com is to help and enable students to compete academically. The website does not provide ghostwriting services and has ZERO TOLERANCE towards misuse of the services. In case any user is found misusing our services, the user's account will be immediately terminated.
Copyright © 2009-2023 UrgentHomework.com, All right reserved.