C Programming - Input / Output - Discussion
Discussion Forum : Input / Output - Find Output of Program (Q.No. 6)
6.
What will be the output of the program ?
#include<stdio.h>
int main()
{
printf("%c\n", ~('C'*-1));
return 0;
}
Discussion:
32 comments Page 4 of 4.
Noureen said:
7 years ago
Very well explained, Thanks @Mohd Pv Vanimal.
Digvijay said:
3 years ago
ASCII value of 67 is (01000011).
67*-1= -67.
In C negative values are treated with 2's complement so its 1's complement is 10111100 + 1.
Its 2's complement is 10111101.
Now apply ~ to its 2's complement.
Therefore it becomes- 01000010.
It's the ASCII value of B(66).
67*-1= -67.
In C negative values are treated with 2's complement so its 1's complement is 10111100 + 1.
Its 2's complement is 10111101.
Now apply ~ to its 2's complement.
Therefore it becomes- 01000010.
It's the ASCII value of B(66).
(7)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers