Functions and Pointers questions

Q13

GATE CS 2024 CS-2C ProgrammingMCQ1 mark−1/3 if wrong
Consider the following C program. Assume parameters to a function are evaluated from right to left.
#include <stdio.h>
int g(int p) { printf("%d", p); return p; }
int h(int q) { printf("%d", q); return q; }
void f(int x, int y) {
    g(x);
    h(y);
}
int main() {
    f(g(10),h(20));
}
Which one of the following options is the CORRECT output of the above C program?
Show answer without attempting

Answer: A

Q33

GATE CS 2024 CS-2C ProgrammingMSQ1 mark
Consider the following C function definition.
int fX(char *a){
    char *b = a;
    while(*b)
        b++;
    return b - a;
}
Which of the following statements is/are TRUE?
More than one option can be correct.
Show answer without attempting

Answer: A, B, D

Q36

GATE CS 2024 CS-2C ProgrammingMCQ2 marks−2/3 if wrong
What is the output of the following C program?
#include <stdio.h>
int main() {
    double a[2]={20.0, 25.0}, *p, *q;
    p = a;
    q = p + 1;
    printf("%d,%d", (int)(q - p), (int)(*q - *p));
    return 0;
}
Show answer without attempting

Answer: B

0/30 correct0 marks

Related topics in C Programming