Vidyalelo
C Programming · Q57

Arrays and Strings

Programming · C Programming · question 57

Q57

What will be the output of the program? #include #include void main() char str[] = "Exam\0Veda"; printf("%s", str);

A.
Exam
Answer
B.
Exam Veda
C.
Exam\0Veda
D.
Veda
E.
None of these

Answer: Option A

Solution

Answer: Option A
Solution:

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".