Two's compliment of -5

Answers were Sorted based on User's Feedback



Two's compliment of -5..

Answer / vignesh1988i

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..

Answer / ramprasad g

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..

Answer / ataraxic

Or in other words
~5+1

Is This Answer Correct ?    6 Yes 3 No

Two's compliment of -5..

Answer / vadivel t

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

Post New Answer

More C Interview Questions

What is a char c?

0 Answers  


Why is conio.h not required when we save a file as .c and use clrscr() or getch() ?

2 Answers  


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

0 Answers  


in one file global variable int i; is declared as static. In another file it is extern int i=100; Is this valid ?

4 Answers   Infosys, NetApp,


What is assignment operator?

0 Answers  






what is unsigened char and what is the difference from char

2 Answers  


Are the expressions * ptr ++ and ++ * ptr same?

0 Answers  


1. Write a C program to count the number of occurrence of a specific word in the given strings. (for e.g. Find how many times the word “live” comes in the sentence “Dream as if you’ll live forever, live as if you’ll die today ”)

12 Answers   Eskom, TCS,


what is the output? #define fun(a,b,t) (g ##t=(a),(a)=(b),(b)=g##t) float gfloat; main() { float a=1.12,b=3.14; fun (a,b,float); printf("na=%4.2f,b=%4.2f",a,b); } A)Error in Defining Macro B)a=1.12,b=3.14 C)a=3.14,b=1.12 D)None of the Above

3 Answers   Accenture, Infosys, Wipro,


find the sum of two matrices and WAP for it.

0 Answers   Huawei,


How can you access memory located at a certain address?

0 Answers  


1)what are limitations for recursive function? 2)write a program to read a text file and count the number of characters in the text file

1 Answers  


Categories