7 7 votes What is the output of the following code snippet? #include <stdio.h> int main() { char c=125; c=c+10; printf("%d",c); return 0; } Programming in C tbb-programming-2 numerical-answers programming-in-c output + – Bikram 998 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
Best answer 21 21 votes Char is of 1 Byte range of singed char = {-2^n -1 to +2^n-1} = -128 to +127 char c =125 125+1= 126 125+2= 127 125+3=-128 125+4=-127 125+5=-126 125+6=-125 125+7=-124 125+8=-123 125+9=-122 125+10=-121 Akash Mittal answered Jul 24, 2017 • selected Jul 24, 2017 by Bikram Akash Mittal comment Share Follow See 1 comment 1 1 comment reply arya_stark commented Aug 8, 2018 reply Follow flag Opsss.... silly question.... 0 0 replyShare Please log in or register to add a comment.
8 8 votes (125= 01111101) + (10=00001010) = 10000111... showing overflow as addition of two positive numbers giving negative result. Content of register = 10000111= -121 ( -2^7 + 7) Niket Gangwar answered Nov 1, 2017 Niket Gangwar comment Share Follow See 1 comment 1 1 comment reply Hemant Parihar commented Nov 1, 2017 reply Follow flag Nice :) 1 1 replyShare Please log in or register to add a comment.