Examveda
Examveda

Determine Output:
void main()
{
      char not; 
      not = !2;
      printf("%d", not);
}

A. 2

B. Garbage Value

C. 0

D. None of These

Answer: Option C

Solution(By Examveda Team)

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


This Question Belongs to C Program >> C Miscellaneous

Join The Discussion

Comments ( 1 )

  1. Madhuri Anagha
    Madhuri Anagha :
    5 years ago

    Can a number be assigned to the char data type?

Related Questions on C Miscellaneous