Home / C Programming / Arrays :: Discussion

Discussion :: Arrays

  1. What will be the output of the program ?

    #include

    #include

    void main()

    {

    char str[] = "Exam\0Veda";

    printf("%s", str);

    }

  2. A.

     Exam

    B.

     Exam Veda

    C.

     Exam\0Veda

    D.

     Veda

    E.

     None of these

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    A string is a collection of characters terminated by '\0'.

    >> char str[] = "Exam\0\Veda\0"; The variable str is declared as an array of characters and initialized with value "Exam".

    >> printf("%s", str); It prints the value of the str.
    The output of the program is "Exam".


Be The First To Comment