Pointers


  1. What type of initialization is needed for the segment “p[3] = ‘3’;” to work?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    char p[] = “Interview!”;


  1. Comment on the output of the following C code.
    #include <stdio.h>
    int main()
    {
    char *s = "Interveiw" //Line 1
    char *p = "Mania\n"; //Line 2
    s = p; //Line 3
    printf("%s, %s\n", s, p); //Line 4
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Memory holding “this” loses its reference at line 3



  1. What will be the output of the following C code?
    #include <stdio.h>
    void function(char *p)
    {
    printf("%s", p);
    }
    void main()
    {
    char str[] = "Interveiw Mania";
    function(str);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Interveiw Mania


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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    E



  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    char *String = "Interveiw Mania";
    char StringArray[] = "Interveiw Mania";
    printf("%d %d\n", strlen(String), strlen(StringArray));
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    15 15