Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by Christian Ancona ( 12 years ago )
/* Jeff Wood
 * IT/218 Week 5 assignment part 1-pass by pointer
 */

#include<iostream>

using std::cin;
using std::cout;
using std::endl;

//initialize arrays
int incr10(int* numa,int* numb);

int main(void)
{
  cout << "Week 5 assignment part 1-Pass by pointer" << endl << endl;
  
  int numa = 3;
  int numb = 32;
  
  int* pnuma = &numa;                           //pointer to numa
  int* pnumb = &numb;                           //pointer to numb
  
  cout << endl
       << "Address Pass (numa)= " << pnuma;
  
  cout << endl
       << "Address Pass (numb)= " << pnumb;
       

  int result = incr10(pnuma,pnumb);
  
  cout << endl
       << "incr10(pnuma) = " << result (numa);
  
  cout << endl
       << "numa = " << numa;
  
  cout << endl;

  cout << endl
       << "incr10(pnumb) = " << result (numb);
  
  cout << endl
       << "numb = " << numb;
  
  cout << endl;
  
  
  return 0;
}


//function to increment a variable by 10
int incr10(int* numa,int* numb)
{
  cout << endl
       << "Address received (numa)= " << numa;

  cout << endl
       << "Address received (numb)= " << numb;
  
  numa += 10;                              // Increment argument
  numb += 10;

  return *numa,*numb;                      // return the increment value
}

 

Revise this Paste

Parent: 27705
Your Name: Code Language: