Home / C Programming / Strings :: Discussion

Discussion :: Strings

  1. What will be the output of the program ?

     #include
     #include 
    
     int main()
     {
         char str[] = "Fresher0\GATE\0";     
         printf("%d\n", strlen(str));     
         return 0;
     } 
    

  2. A.

    10

    B.

    6

    C.

    5

    D.

    11

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    The function strlen returns the number of characters int the given string.

    Therefore, strlen(str) becomes strlen("India") contains 5 characters. A string is a collection of characters terminated by '\0'.

    The output of the program is "5".


Be The First To Comment