Click here to Skip to main content
14,243,202 members
Rate this:
Please Sign up or sign in to vote.
See more:
#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

Rate this:
Please Sign up or sign in to vote.

Solution 2

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.
   
v2

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100