Click here to Skip to main content
15,887,254 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
XML
#include <iostream.h>
#include <conio.h>
void main()
{
  clrscr();
  int sum(int );
  int mynumber=20;

  mynumber=sum(mynumber);
  cout<<mynumber;
  getch();
}

int sum(int number)
{

  number=number+5;
  return number;

}


my question is that from above i think i have change the modify the value of variable actual mynumber with out using passing pointer as arguments to function

then why we pointers as arguments to function
Posted
Updated 11-Apr-13 5:25am
v3

1 solution

Quote:
e i think i have change the modify the value of variable actual mynumber with out using passing pointer as arguments to function

No you did not.
You actually modified mynumber in the main function using the return value provided by the sum function.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900