Home » C Programming » Pointers » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    char *str = "InterviewMania";
    char *ntr = "Mania";
    char *ptr = str + ntr;
    printf("%c\t%c", *ptr, str[1]);
    }
    1. InterviewMania
    2. Mania
    3. Compilation Error
    4. I M
    5. None of these
Correct Option: C

Compilation Error

main.c: In function ‘main’:
main.c:6:25: error: invalid operands to binary + (have ‘char *’ and ‘char *’)
char *ptr = str + ntr;



Your comments will be displayed only after manual approval.