Determine Output:
void main()
{
char a[]="12345";
int i = strlen(a);
printf("%d", ++i);
}
void main()
{
char a[]="12345";
int i = strlen(a);
printf("%d", ++i);
}
A. 5
B. 6
C. 7
D. None of These
Answer: Option B
Solution(By Examveda Team)
The char array 'a' will hold the initialized string, whose length will be counted from 0 till the null character. Hence the 'i' will hold the value equal to 5, after the pre-increment in the printf statement, then 6 will be printed.
Join The Discussion
Comments ( 3 )
Related Questions on C Miscellaneous
Determine output:
void main()
{
int const *p=5;
printf("%d", ++(*p));
}
A. 6
B. 5
C. Garbage Value
D. Compiler Error
A. mmm nnn aaa
B. mmmm nnnn aaaa
C. Compiler Error
D. None of These
A. I hate Examveda
B. I love Examveda
C. Error
D. None of These
Determine Output:
void main()
{
static int var = 5;
printf("%d ", var--);
if(var)
main();
}
A. 5 5 5 5 5
B. 5 4 3 2 1
C. Infinite Loop
D. None of These
Ans must be 7
answer is compilition error since header file is not written completely.
7 is the answer