0

/* I'm new on c ++ and i been strugling with this problem.
create the special functions used by this routine and
write the functions so it can be used by the main routine as shown*/

#include <stdio.h>
#include <stdlib.h>

Void powerArgs(int *parmA, int *parmB)
{
int temp = *parmA;
*parmA = *parmB;
*parmB = temp;
}

/* MAIN */
int main(int argc, char **argv) {
if (argc != 3) {
printf("?Invalid number of arguments\n");
system("pause");
exit(1);
}
int parmA = atoi(argv[1]);
int parmB = atoi(argv[2]);




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 %.0lf\n",parmA,parmB,*powerArgs(&parmA, &parmB));
parmA = atoi(argv[1]);
parmB = atoi(argv[2]);


}
printf("\n"); 

system("pause");
exit(0);
}
3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
0

No capital letter in void:

void powerArgs(int *parmA, int *parmB)
{
int temp = *parmA;
*parmA = *parmB;
*parmB = temp;
}
0

The code you posted is C, not C++.

/* Reset the original values after we print the result */// printf("%d raised to the %d power is %.0lf\n",parmA,parmB,*powerArgs(&parmA, &parmB));

Sorry, but your version of powerArgs() doesn't raise paramA to the power of paramB. Nor does it return anything so you can't put it in a printf() statement like that.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.