[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

C Programming :: Declarations and Initializations - Discussion

Home > C Programming > Declarations and Initializations > MCQs Questions Discussion

4 / 54

What is the output of the following 'C' program?

#include <stdio.h>
void main(){
char c=125;
    c=c+10;
    printf("%d",c);
}

A135

BINF

C-121

DCompilation Error

Answer: Option (Login/Signup)

Show Explanation

Here char is signed so,the size of char is 1 bytes and its value range are -128 to 127,



and it will be something like below



-128 -127 -126 .......... 0 ....... 126 127 in the cycle. 



Now as per questions c = 125 it is under the above limit.



but when 10 added to it, it becomes 125 10 = 135



125 126 127 -128 -127 -126 -125 -124 -123 -122 -121 



So, count above 135 will fall at -121, so Answer will be -121



If in the question it would have given unsigned char then answer will be 135

Asked In ::

Post Your Answer Here:     

Reply    
Rate This: +2 -0 +
    Report


Report Error

Please Login First Click Here

Reply    
Rate This: +2 -0 +
    Report


Report Error

Please Login First Click Here

Reply    
Rate This: +0 -0
    Report


Report Error

Please Login First Click Here

Reply    
Rate This: +0 -0
    Report


Report Error

Please Login First Click Here