This is an assignment for my class, any links to where I can find out what my teacher is trying to get us to learn would be great. I am suppose to keep everything the same and just fix the commands so they work.
#include <stdio.h>
#include <stdlib.h>
/* 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]);
/* 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);
printf("Swapped values A=%d, B=%d.\n",parmA,parmB);
parmA = atoi(argv[1]);
parmB = atoi(argv[2]);
/* 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);
printf("%d, remainder is %d\n",parmA,parmB);
parmA = atoi(argv[1]);
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 %.0lf\n",parmA,parmB,*powerArgs(&parmA, &parmB));
parmA = atoi(argv[1]);
parmB = atoi(argv[2]);
/* Extra credit: Fibonacci generator function. The first call to fibArgs returns the
first Fibonacci number (0) and each subsequent call to fibArgs returns the
next Fibonacci number. In this case parmA will specify the number of
Fibonacci numbers to display. Fibonacci numbers:
F(0) = 0
F(1) = 1
F(n) = F(n-1)+F(n-2)
The first few numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55
*/
int idx;
printf("The first %d Fibonacci Numbers are: ",parmA);
for(idx=0; idx < parmA; idx++) {
printf(" %d",*fibArgs());
}
printf("\n");
system("pause");
exit(0);
}