Skip to content

ISRO Scientist/Engineer CSE 2020Programming in C › Pointers and Arrays

ISRO Scientist/Engineer CSE 2020 PYQ: What is the output of the code given below? # include<stdio.h> int main() { char name[]="satellites"; int…

What is the output of the code given below?

# include<stdio.h>
int main()
{
    char name[]="satellites";
    int len;
    int size;
    len= strlen(name);
    size = sizeof(name);
    printf("%d",len*size);
    return 0;
}
  1. A
    100
  2. B
    110
    Correct answer
  3. C
    40
  4. D
    44

Answer

(B) $110$

Approach

The code computes len = strlen(name) and size = sizeof(name), then prints len * size. For the string literal "satellites", strlen returns the number of characters before the null terminator, while sizeof returns the total bytes of the array including the null terminator. Multiply these two values to get the output.

Reviewed by ISRO IQ Editorial Team.