Skip to content

Instantly share code, notes, and snippets.

@lacytimlick
Last active December 29, 2015 12:39
Show Gist options
  • Save lacytimlick/7671650 to your computer and use it in GitHub Desktop.
Save lacytimlick/7671650 to your computer and use it in GitHub Desktop.
In this lab you will create a single source code file called PointerFunctions.c that uses the main routine shown below: 1. You will provide the functionality for the functions in blue 2. Your task is to create the special functions used by this routine, which are shown in blue in the above program. The special functions are swapArgs, divideArgs …
#include <stdio.h>
#include <stdlib.h>
/* MAIN */
int main() {
int parmA, parmB;
int parma, parmb; // used later to reset
printf("Enter 2 integers ");
scanf("%d %d", &parmA, &parmB);
parma = parmA;
parmb = parmB;
/* Part A: Swap the values. Value in parmA is moved to parmB and vice versa */
/* Reset the original values after we print the result */
printf("A=%d, B=%d. ",parmA,parmB);
swapArgs(&parmA,&parmB);
parmA = parma;
parmB = parmb;
/* Part B: Divide parmA by parmB. Put the quotient in parmA, remainder in parmB */
/* Reset the original values after we print the result */
printf("Quotient of %d / %d is ",parmA,parmB);
divideArgs(&parmA, &parmB);
parmA = parma;
parmB = parmb;
/* Part C: Raise parmA to the power of parmB. Return pointer to the result */
/* Reset the original values after we print the result */
printf("%d raised to the %d power is ",parmA,parmB);
printf("%.0lf \n", *powerArgs(&parmA, &parmB);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment