Chapter 9

  1. A formal argument is a variable that is defined in the function being called. The actual argument is the value appearing in the function call; this value is assigned to the formal argument. You can think of the actual argument as being the value to which the formal argument is initialized when the function is called.

    1. void donut(int n)

    2. int gear(int t1, int t2)

    3. void stuff_it(double d, double *pd)

    1. char n_to_char(int n)

    2. int digits(double x, int n)

    3. int random(void)

  2. int sum(int a, int b){
        return a + b;
    }
    
  3. Replace int with double throughout:

    double sum(double a, double b)
    {
        return a + b;
    }
    
  4. This function needs to use pointers:

    void alter(int * pa, int * pb)
    {
        int temp;
        temp = *pa + *pb;
        *pb = *pa - *pb;
        *pa = temp;
    }
    

    or

     void alter(int * pa, int * ...

Get C Primer Plus®, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.