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 2 of 4.
Satya said:
1 decade ago
@Nik because c language follows the one's complement signed number representation
Rahul said:
9 years ago
Thank you all for such a wonderful help. It is very helpful.
Nik said:
1 decade ago
How come bitwise not (~) to -67 is 66 , why not 67 itself?
Tarun said:
1 decade ago
~n=-(n+1)
'c'*(-1)=67*(-1)=-67
~(-67)=-(-67+1)=66
66='B'
'c'*(-1)=67*(-1)=-67
~(-67)=-(-67+1)=66
66='B'
(1)
Venkat said:
1 decade ago
Here 01000010 = 66 can be like 2^1+2^6 = 2+64 = 66.
Balaji said:
1 decade ago
-67 is stored in 2's complement form in computer.
Sowmiya said:
9 years ago
How ~67 comes to 66? Can someone explain please.
Anu said:
1 decade ago
How 01000010 is 66? Can someone explain please?
Noureen said:
7 years ago
Very well explained, Thanks @Mohd Pv Vanimal.
Prashanth said:
1 decade ago
Why to use 1's compliment? Any one please.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers