- Is
fprintf(stdout, "xxx")
the same asprintf("xxx")
? - When should we use assertions instead of an if statement?
- What will happen if you pass an
int
variable to a function that takes adouble
as its parameter? What will happen if adouble
is passed to anint
parameter? - What is “pass by value”?
- 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; }
- How do you change the main function so that it can accept command-line arguments?
- Write a short C program that takes two integers from the command line and prints their sum, difference, and product.