CSE101Lec14callbyvalue.ppt - CSE101-Lec#14 \u2022 Function Call \u00a9LPU CSE101 C Programming Outline \u2022 Function call \u2013 Passing arguments by value \u2013

CSE101Lec14callbyvalue.ppt - CSE101-Lec#14 u2022 Function...

This preview shows page 1 - 6 out of 16 pages.

©LPU CSE101 C ProgrammingCSE101-Lec#14Function Call
Background image
©LPU CSE101 C ProgrammingOutlineFunction callPassing arguments by valuePassing arguments by reference
Background image
©LPU CSE101 C ProgrammingFormal Arguments and Actual ArgumentsArgument: An argument is an expression which is passed to a function by its caller in order for the function to perform its task.Actual arguments: The arguments that are passed in a function call are called actual arguments. These arguments are defined in the calling function.Formal arguments: The formal arguments are the parameters/arguments in a function definition. Formal arguments are a copy of the actual arguments.
Background image
©LPU CSE101 C Programming#include <stdio.h> void sum(int i, int j, int k); /*function prototype*/int main() { int a = 5; sum(3, 2 * a, a); // actual argumentsreturn 0; } void sum(int i, int j, int k)//formal arguments { int s; s = i + j + k; printf("sum is %d", s); }
Background image
©LPU CSE101 C ProgrammingMethods of passing argumentsThere are two ways to call a function/to pass arguments to a function:1.Call by value2.Call by reference
Background image
Image of page 6

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture