Pointers


  1. What will be the output of the following C code?
     #include <stdio.h>
    void count(char *ptr)
    {
    ptr++;
    ptr[3] = 'S';
    }
    void main()
    {
    char str[] = "AJIT";
    count(str);
    printf("%c\n", *str);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    A


  1. Calling a function fun with num an array variable num[3] where num is an array, is equivalent to __________.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Option A, B and C is equivalent.



  1. What is the correct way to declare and assign a function pointer?
    (Assuming the function to be assigned is "int multi(int, int);")











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    int (*fn_ptr)(int, int) = multi;


  1. What will be the output of the following C code?
    #include <stdio.h>
    int calc(int n, int m)
    {
    return n + m;
    }
    int main()
    {
    int (*calc_ptr)(int, int);
    calc_ptr = calc;
    printf("The Addition of two numbers is: %d", (int)calc_ptr(21, 13));
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    34



  1. What is the syntax for constant pointer to address (i.e., fixed pointer address)?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    <type> * const <name>