Two's compliment of -5

Answers were Sorted based on User's Feedback

Two's compliment of -5..

first write the given number in it's binary format.
am considering only 8 bit at a time ,
5- 0000 0101
step 1: convert this binary format to one's compliment (ie)
change 0 to 1 and 1 to 0.
1111 1010

step 2: add 1 to the above binary format.

1111 1010
1
-----------
1111 1011

so this binary format will get stored in memory and the sign
bit will be set to 1.

always the negative number will be stored only in 2's
compliment..........

thank u

 Is This Answer Correct ? 20 Yes 2 No

Two's compliment of -5..

ans: +5

-5 will be stored as 2's complement of 5
2's complement of -5, is thus 2 times 2's complement of 5.
so the ans is 5 itself.

 Is This Answer Correct ? 11 Yes 0 No

Two's compliment of -5..

Or in other words
~5+1

 Is This Answer Correct ? 6 Yes 3 No

Two's compliment of -5..

2's compliment of a -ve no is, positive value of the same
no.

#include<stdio.h>
#include<conio.h>
void main()
{
int no1, res;
printf("ENTER THE NEGATIVE NO: \n");
scanf("%d", &no1);
no1 = ~(no1);
res = no1 | 0x01;
printf("\nRESULT: %d", res);
getch();
}

 Is This Answer Correct ? 0 Yes 5 No

More C Interview Questions

what are bit fields in c?

What is the exact difference between '\0' and ""

ABCDCBA ABC CBA AB BA A A

main() { static int ivar=5; printf("%d",ivar--); if(ivar) main(); }

What are the key features in c programming language?

a 'c' program to tell that the set of three coordinates lie on a same line

#include<stdio.h> main(0 { printf("\n %d %d %d",sizeof(3),sizeof("3"),sizeof(3)); }

what is the difference between while and do while?

i want to know aptitude questions,technical questions

How can a program be made to print the name of a source file where an error occurs?

any string of bits of length 'n' represents a unique non- negative integer between.............?

write a program that explain #define and # undef directive

Categories
• C (3865)
• C++ (2437)
• VC++ (416)
• Delphi (566)
• Python Related (1981)
• PHP Related (4990)
• Scala (319)
• R Programming (395)
• Kotlin (184)
• Apache Groovy (39)
• Ruby (244)
• Go Programming Language (139)
• Objective-C (100)
• Programming Languages AllOther (735)