Functions and Pointers questions

Q12

GATE CS 2016 CS-1C ProgrammingMCQ1 mark−1/3 if wrong
Consider the following C program.
void f(int, short);
void main()
{
    int i = 100;
    short s = 12;
    short *p = &s;
    __________ ;    // call to f()
}
Which one of the following expressions, when placed in the blank above, will NOT result in a type checking error?
Show answer without attempting

Answer: D

Q15

GATE CS 2016 CS-1C ProgrammingNAT1 mark
Consider the following C program.
#include<stdio.h>
void mystery(int *ptra, int *ptrb) {
    int *temp;
    temp = ptrb;
    ptrb = ptra;
    ptra = temp;
}
int main() {
    int a=2016, b=0, c=4, d=42;
    mystery(&a, &b);
    if (a < c)
        mystery(&c, &a);
    mystery(&a, &d);
    printf("%d\n", a);
}
The output of the program is ________.
Show answer without attempting

Answer: 2016.0

Q12

GATE CS 2016 CS-2C ProgrammingNAT1 mark
The value printed by the following program is _________.
void f(int* p, int m){
    m = m + 5;
    *p = *p + m;
    return;
}

void main(){
    int i=5, j=10;
    f(&i, j);
    printf("%d", i+j);
}
Show answer without attempting

Answer: 30.0

0/30 correct0 marks

Related topics in C Programming