Examveda
Examveda

What will be the output of the program?
#include<stdio.h>
#include<string.h>
void main()
{
    char str[] = "Exam\0Veda";
    printf("%s", str);
}

A. Exam

B. Exam Veda

C. Exam\0Veda

D. Veda

E. None of these

Answer: Option A

Solution(By Examveda Team)

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


This Question Belongs to C Program >> Arrays And Strings

Join The Discussion

Related Questions on Arrays and Strings