Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

C | C Quiz – 113 | Question 1

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Output of following program under the assumption that numbers are stored in 2’s complement form.

int main()
   printf("%c\n", ~('C' * -1));
   return 0;

Contributed by Sowmya.L.R
(A) B
(B) A
(C) Compiler Error
(D) C

Answer: (A)

Explanation: executed without any error or warning messages and the output for the above code is
The above program processes as below
Step 1:
First (‘C’ *-1) is processed
ASCII value of ‘C’ is 67 and it is multiplied with -1 as
67 * (-1) = -67
Step 2:
The binary representation of -67 is 10111101
The bitwise negation of 10111101 becomes (01000010 ) 2 = (66) 10
Step 3:
66 is the ASCII value of ‘B’
So ~(‘C’*-1) = 66 and so the output of the above the program is B

Quiz of this Question

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads