C Miscellaneous - Study Mode
[#91] Determine Output: void main()
{
char not
not = !2
printf("%d", not)
}
Correct Answer
(C) 0
Explanation
Solution: ! is a logical operator. In C the value 0 is considered to be the boolean value FALSE, and any non-zero value is considered to be the boolean value TRUE. Here 2 is a non-zero value so TRUE. !TRUE is FALSE (0) so it prints 0.
[#92] Determine Output: #include<stdio.h>
void main()
{
register i=5
char j[]= "hello"
printf("%s %d", j, i)
}
Correct Answer
(A) hello 5
Explanation
Solution: If you declare i as register compiler will treat it as ordinary integer and it will take integer value. i value may be stored either in register or in memory.
[#93] Determine Output: void main()
{
int i=5, j=6, z
printf("%d", i+++j)
}
Correct Answer
(C) 11
Explanation
Solution: The expression i+++j is treated as ((i++) + j)
[#94] Determine Output: void main()
{
int i = abc(10)
printf("%d", --i)
}
int abc(int i)
{
return(i++)
}
Correct Answer
(B) 9
Explanation
Solution: " return ( i++ ) ", it will first return i and then increment it. i.e. 10 will be returned.
[#95] Determine Output: void main()
{
char a[]="12345"
int i = strlen(a)
printf("%d", ++i)
}
Correct Answer
(B) 6
Explanation
Solution: 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.