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 3 of 4.
Anil said:
1 decade ago
Hariraj is right.
Balaji said:
1 decade ago
-67 is stored in 2's complement form in computer.
Rhana said:
1 decade ago
Hariraj is right.
Sindhu said:
1 decade ago
Is ~ of all negative numbers result in positive numbers whose value is one less than its negative value?
Vivek said:
1 decade ago
For using ~
first we will add 1 to the number and then we will change the sign.
for ex:
-67
-67+1=-66
and now we will change the sign that is equal to 66
how we use this sign ~.
first we will add 1 to the number and then we will change the sign.
for ex:
-67
-67+1=-66
and now we will change the sign that is equal to 66
how we use this sign ~.
Dhan said:
1 decade ago
For -67 we can calculate the binary value by:
First find binary value for 67
67=01000011
take 1's complement:
that is make 0's complement and add 1
10111100+1=10111101
First find binary value for 67
67=01000011
take 1's complement:
that is make 0's complement and add 1
10111100+1=10111101
Nita said:
1 decade ago
Hariraj is right.
Chaudhary paresh said:
1 decade ago
('C'*-1)--> ASCII Value of C equal to 67 so statement become(67*-1)=-67
~ indicate one's complement in c
~(-67)=66 so 66 ASCII value of character 'B'
~ indicate one's complement in c
~(-67)=66 so 66 ASCII value of character 'B'
Mah said:
1 decade ago
Thank you hariraj.
Satya said:
1 decade ago
@Nik because c language follows the one's complement signed number representation
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers