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;
}
A
B
C
D
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
32 comments Page 3 of 4.

Anu said:   1 decade ago
How 01000010 is 66? Can someone explain please?

Venkat said:   1 decade ago
Here 01000010 = 66 can be like 2^1+2^6 = 2+64 = 66.

Sowmiya said:   9 years ago
How ~67 comes to 66? Can someone explain please.

Alok said:   9 years ago
@Vallabh is correct.

Rahul said:   9 years ago
Thank you all for such a wonderful help. It is very helpful.

Jayant said:   8 years ago
You are right @Vallabh.

Aminul said:   8 years ago
Yes, Right @Venkat.

Pallavi said:   8 years ago
Agree @Venkat.

Mayank said:   8 years ago
Very nice explanation @Vallabh.

Mohd pv vanimal said:   7 years ago
include<stdio.h>
int main()
{
printf("%d\n", 'C'); //67
printf("%d\n", 'C' * -1); //-67
printf("%d\n", ~('C' * - 1)); //66
printf("%c\n",~('C' * -1)); //B
return 0;
}

In 2's complement, the value of ~(-67) is 66.
(2)


Post your comments here:

Your comments will be displayed after verification.