Created
April 11, 2014 03:11
-
-
Save aeonblue3/10438937 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
/** | |
* The purpose of this program is to create two integer variables and assign | |
* each a value. Then the values are passed to a function that alter their | |
* values without needint to reference a global variable or returning any | |
* values. | |
* | |
* @author Chris Neitzer | |
* Discussion Forum 3 | |
*/ | |
/* Prototype for myFunc */ | |
void myFunc(float *argument_one, float *argument_two); | |
int main() | |
{ | |
/* Assign integer values to two variables of type integer */ | |
float var_1 = 3.14, var_2 = 6.28; | |
/* Print out the initial values of the variables */ | |
printf("The value of var_1 was %4.2f and var_2 was %4.2f, ", var_1, var_2); | |
/* Pass the reference, or pointer, to the two previously declared integer | |
* variables. */ | |
myFunc(&var_1, &var_2); | |
/* Now, print out the altered values of the two variables declared at the | |
* beginning of the main function. */ | |
printf("but now var_1 is %4.2f and var_2 is %4.2f!\n", var_1, var_2); | |
fflush(stdin); /* clear input area so you can pause */ | |
printf("Press the key to exit program."); | |
getchar(); /* force the computer to pause until you press a key on the keyboard */ | |
return 0; | |
} | |
/** | |
* myFunc accepts two integer pointers as arguments and assigns new values to | |
* them. | |
*/ | |
void myFunc(float *argument_one, float *argument_two) | |
{ | |
*argument_one = 41.3; | |
*argument_two = 82.6; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment