Code:
int parmA = atoi(argv[1]);
int parmB = atoi(argv[2]);
/* 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);
...
double powerArgs(double *a, double *b)
{
double powerArgs = pow ((double) *a, (double) *b);
return powerArgs;
}
The call of the powerArgs function has a couple problems beyond those that may have been discussed already. The first is that the printf line contains 2 open parenthesis but only 1 closing parenthesis. The second is that parmA and parmB are type int but you are passing them to a function that expects type double* for some reason. For what the function does, there is no reason to pass any pointers into this function at all, you can simply pass the values.
Code:
/* 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 = atoi(argv[1]);
parmB = atoi(argv[2]);
...
int divideArgs(int *a, int *b)
{
int tempA = *a, tempB = *b;
double divisor = *a / *b;
*a = (long) divisor;
*b = divisor - *a;
printf("%d, with the remainder being %f\n", *a, *b);
*a = tempA;
*b = tempB;
}
Your divideArgs function does not return a value like you say it should. Though it probably should not do so anyway as mentioned in my next paragraph below.
The divideArgs function itself seems a poor place to be doing output directly as your functions seem to be mixing behavior - divideArgs outputs a value and is supposed to return a value but does not and on the other hand the powerArgs function is returning a value which you are attempting to print elsewhere (incorrectly)... this can be confusing. Given what the function does, I would calculate the result and remainder of the division and pass these back through the input parameters. Back in main I would then print the modified parmA/parmB before doing the reset. The function would not need a return value in this case. You might want to add a check so you don't attempt a divide by 0.
You are also doing integer division and assigning this result to a double and then casting the double to a long and then assigning back to an int. WTF?
You are also printing an int using a %f (float) specifier.
Code:
/* 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 = atoi(argv[1]);
parmB = atoi(argv[2]);
According to the description for part A, shouldn't you do the swap before you print the values and then reset parmA/parmB?
Boy, the more I look the more I find. This needs some serious work/redesign.