Skip to content
Related Articles

Related Articles

ISRO | ISRO CS 2020 | Question 36

Improve Article
Save Article
  • Last Updated : 04 Sep, 2020
Improve Article
Save Article

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;
 }


(A) 100
(B) 110
(C) 40
(D) 44


Answer: (B)

Explanation: Note –

  • strlen() function returns length of string without null character.
  • sizeof() function returns size of string with null character.
  • sizeof() = strlen() + 1

Therefore, 110 will be printed.




#include <stdio.h> 
#include <cstring>
  
int main( ) 
 
   char name[ ]="satellites"
   int len; 
   int size; 
   len = strlen(name); 
   size = sizeof(name); 
   printf("%d", len * size); 
   return 0; 
 


Option (B) is correct.

Quiz of this Question

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!