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

Compilation Error

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



Your comments will be displayed only after manual approval.