Pointers


  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()
    {
    int array[3] = {16, 17, 18};
    int *p = &array[1];
    float m = 1;
    p = p + m;
    printf("%d\n", *p);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Compilation Error

    main.c: In function ‘main’:
    main.c:7:15: error: invalid operands to binary + (have ‘int *’ and ‘float’)
    p = p + m;


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    char *str = "Interview, Mania\n";
    char *strc = "Welcome to\n";
    strcpy(strc, str);
    printf("%s\n", strc);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Crash/segmentation fault



  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int arr[5] = {61, 62, 63, 64, 65};
    void *p = &arr[1];
    void *p1 = &arr[5];
    int Res = 0;
    Res = p1 - p;
    printf("%d\n", Res);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    16