pointer example

pointer example - / CS 31 Example Program / February 20,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 // CS 31 Example Program // February 20, 2008 // John A. Rohr // Pointer Function Examples #include <iostream> #include <iomanip> using namespace std void exchangeV(int p1, int p2) void exchangeP(int* p1, int* p2) void greaterVP(int* p1, int *p2, int* gr) int* greaterPRV(int* p1, int* p2) int main() { int num1 int num2 int ans int *p1 int *p2 int *pans // Set values num1 = 1 num2 = 2 // Display the values cout << "Main Program Before Call: num1 = " << num1 << endl cout << "Main Program Before Call: num2 = " << num2 << endl // Call the exchange function with value parameters exchangeV(num1, num2) // Display the values cout << "Main Program After Call: num1 = " << num1 << endl cout << "Main Program After Call: num2 = " << num2 << endl
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sheet1 Page 2 // Display a blank line cout << endl // Set values num1 = 3 num2 = 4 // Display the values cout << "Main Program Before Call: num1 = " << num1 << endl cout << "Main Program Before Call: num2 = " << num2 << endl // Call the exchange function with pointer parameters // Display the values cout << "Main Program After Call: num1 = " << num1 << endl cout << "Main Program After Call: num2 = " << num2 << endl // Display a blank line cout << endl // Set values num1 = 5 num2 = 6 // Display the values cout << "Main Program Before Call:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/12/2009 for the course CS 31 taught by Professor Melkanoff during the Winter '00 term at UCLA.

Page1 / 12

pointer example - / CS 31 Example Program / February 20,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online