2,607 views
1 votes
1 votes

Assume that the size of char is 1 byte and negatives are stored in 2's complement form

#include<stdio.h>

int main()

{

    char c = 125;

    c = c+10;

    printf("%d", c);

    return 0;

}

1.135

2.+INF

3.-121

4.-8

1 Answer

Best answer
2 votes
2 votes
Binary form of 125=>01111101

Binary form of 10=>00001010

125+10=10000111    // this is a negative number because sign bit is one

take 2's complement of 10000111 is 01111001

decimal value of 01111001 is 121

so answer is =-121
selected by

Related questions

0 votes
0 votes
2 answers
1
Shashank Kumar Mishr asked May 18, 2017
447 views
What is the output for following code and how integer value can be assigned to a character value?#include <stdio.h>int main(){ char a = 30, b = 40, c = 10; char d =...
1 votes
1 votes
1 answer
2
Shashank Kumar Mishr asked May 17, 2017
712 views
predict the correct options#include <stdio.h>int main(){ if (sizeof(int) -1) printf("Yes"); else printf("No"); return 0;}1.yes2.no3.compiler error...
2 votes
2 votes
1 answer
3
Shashank Kumar Mishr asked May 17, 2017
1,315 views
Predict the output of following program. Assume that the numbers are stored in 2's complement form.#include<stdio.h>int main(){ unsigned int x = -1; int y = ~0; if...