C++ Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
C++ Tutorial
C++ Language Tutorial - Object Oriented Programing - OOPs History of C++
C++ Language Tutorial - Object Oriented Programing - OOPs Structure of C++
C++ Language Tutorial - Object Oriented Programing - OOPs C++ Datatypes
C++ Language Tutorial - Object Oriented Programing - OOPs Variables
C++ Language Tutorial - Object Oriented Programing - OOPs Constants
C++ Language Tutorial - Object Oriented Programing - OOPs Operators
C++ Language Tutorial - Object Oriented Programing - OOPs Control Structures
C++ Language Tutorial - Object Oriented Programing - OOPs Arrays
C++ Language Tutorial - Object Oriented Programing - OOPs Functions
C++ Language Tutorial - Object Oriented Programing - OOPs Class
C++ Language Tutorial - Object Oriented Programing - OOPs Predefined Functions
C++ Language Tutorial - Object Oriented Programing - OOPs I/O Functions
C++ Language Tutorial - Object Oriented Programing - OOPs String, Character Functions
C++ Language Tutorial - Object Oriented Programing - OOPs Mathematical Functions
C++ Language Tutorial - Object Oriented Programing - OOPs Time Date Functions
C++ Language Tutorial - Object Oriented Programing - OOPs Dynamic Allocation
C++ Language Tutorial - Object Oriented Programing - OOPs Utility Functions
C++ Language Tutorial - Object Oriented Programing - OOPs OOP's Concept
C++ Language Tutorial - Object Oriented Programing - OOPs Special Topics
C++ Language Tutorial - Object Oriented Programing - OOPs Type casting
C++ Language Tutorial - Object Oriented Programing - OOPs Feedback
C++ Language Tutorial - Object Oriented Programing - OOPs Ask Your Doubts
 





Pass By Value - Function


Tutorials Cpp

Topic

What is Function Calls?
How to pass by value in C++?



Explanation

Pass by value or Call by value is the method where a copy of the value of the variables are passed to the function to do specific operation to return the result. The actual values of the variable remains unchanged as changes are made to the copied values of the variables.

Example:

  #include <iostream.h>
  multiply(int a, int b)
   {
   	int r;
   	r = a * b;
   	return (r);
   }
  int main()
   {
   	int x,y;
   	cout << "Enter the first integer::"; cin >> x;
   	cout << "Enter the second integer::"; cin >> y;
   	cout << "Product of X and Y is::" <<  multiply(x,y);
   }

Result:
   Enter the first integer::10	
   Enter the second integer::2
   Product of X and Y is::20

In the above example the product of the numbers are calculated by passing the copy of values for "x,y" to the variables "a,b" in the function "multiply" This is the function calls in C++.








Note
C++ is one of the most used programming languages in the world. Also known as "C with Classes". Hope you enjoy this tutorial. Do send your feedback or suggestions on this C++ tutorial. This is a copyright content.

Other Links

web hosting