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);

}

One to see how arguments are passed into an application.
myapp 8 4

They want you to write your missing functions.
So prototype them and pass a 0 response just to rough them in and get a clean compile.
Then start on the first function!

Post your attempts and then we'll review!
(Don't forget to check for zero in the divide!)

The functions are void and the numbers are passed into the function and the results are passed back out! the same way!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.