7 votes 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 + – Bikram asked May 14, 2017 • edited Aug 19, 2019 by Counsellor Bikram 557 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 17 votes 17 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 See all 1 1 comment reply arya_stark commented Aug 8, 2018 reply Follow Share Opsss.... silly question.... 0 votes 0 votes Please log in or register to add a comment.
8 votes 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 See all 1 1 comment reply Hemant Parihar commented Nov 1, 2017 reply Follow Share Nice :) 1 votes 1 votes Please log in or register to add a comment.