Day 6 Recap Questions
  1. Is fprintf(stdout, "xxx") the same as printf("xxx")?
  2. When should we use assertions instead of an if statement?
  3. What will happen if you pass an int variable to a function that takes a double as its parameter? What will happen if a double is passed to an int parameter?
  4. What is “pass by value”?
  5. What is the output of the following code:
    #include <stdio.h>
    void update_values(int x, int y) {
     x = x + 10;
     y = y * 2;
     printf("Inside update_values: x = %d, y = %d\n", x, y);
    }
    int compute_sum(int a, int b) {
     update_values(a, b);
     return a + b;
    }
    int main() {
     int m = 5, n = 7;
     int result = compute_sum(m, n);
     printf("After function calls: m = %d, n = %d\n", m, n);
     printf("Result = %d\n", result);
     return 0;
    }
    
  6. How do you change the main function so that it can accept command-line arguments?
  7. Write a short C program that takes two integers from the command line and prints their sum, difference, and product.