Actual parameter: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Pat Palmer
(reword)
mNo edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{subpages}}
In [[computer science]], an '''actual parameter''' is a name or value passed to a subroutine.  This is in contrast to a [[formal parameter]], which is the name by which the subroutine refers actual parameter.  For example, in [[C (programming language)|C]],
In [[computer science]], an '''actual parameter''' is a name or value passed to a subroutine.  This is in contrast to a [[formal parameter]], which is the name by which the subroutine refers actual parameter.  For example, in [[C (programming language)|C]],


Line 16: Line 18:




The subroutine bar() calls foo().  When bar() calls foo(), it passes the constant 1.  Within bar(), 1 is an actual parameter to foo().  Within foo(), a is a formal parameter which references the actual parameter 1 from bar().
The subroutine bar() calls foo().  When bar() calls foo(), it passes the constant 1.  Within bar(), 1 is an actual parameter to foo().  Within foo(), a is a formal parameter which references the actual parameter 1 from bar().
 
==References==
{{reflist}}


[[Category: Computers Workgroup]]  
[[Category:Flagged for Review]][[Category:Suggestion Bot Tag]]
[[Category: CZ Live]]

Latest revision as of 06:01, 6 July 2024

This article is a stub and thus not approved.
Main Article
Discussion
Related Articles  [?]
Bibliography  [?]
External Links  [?]
Citable Version  [?]
 
This editable Main Article is under development and subject to a disclaimer.

In computer science, an actual parameter is a name or value passed to a subroutine. This is in contrast to a formal parameter, which is the name by which the subroutine refers actual parameter. For example, in C,

int foo(int a)
{
   int b = 5;

   return a + b;
}

int bar(void)
{
   return foo(1);
}


The subroutine bar() calls foo(). When bar() calls foo(), it passes the constant 1. Within bar(), 1 is an actual parameter to foo(). Within foo(), a is a formal parameter which references the actual parameter 1 from bar().

References