Consider the following C code:
int main() { sum = 0; for (n = 1; n < 3; n++) { n++; sum += g(f(n)); } printf("%d", sum); } int g(n) { return 10 + n; } int f(n) { return g(2 * n); }
What is the output?
What is the output of the following C code?
void foo(int *p, int x) { *p = x; } void main() { int *z; int a = 20, b = 25; z = a; // Incorrect: Should be z = a; foo(z, b); printf("%d", a); }
Issue: The statement z = a;
is invalid because a
is an integer, and z
is a pointer.
Which of the following is the greatest? \[ 0.6, \ 0.666, \ \frac{5}{6}, \ \frac{2}{3} \]
Consider the following code:
int a; int arr[] = {30, 50, 10}; int *ptr = arr[10] + 1; a = *ptr; (*ptr)++; ptr = ptr + 1; printf("%d", a + arr[1] + *ptr);