How to find the digits truncation when assigning the
interger variable to the character variables.

like int i=500; char x = i : here we have truncation. how to
find this.

another ex: i =100; char x=i. here we do not have
truncation.



How to find the digits truncation when assigning the interger variable to the character variables...

Answer / ashu

when i=500 in int which means it is not going beyond the limit of integer range in memory but when x=i which means we are assigning value of i to x.. that is now x becomes 500 whose data type is "char" and range is only -128 to 127 in signed & 0 to 255 in unsigned.. i.e. it is crossing the range.. there we find truncation here

where as in 2nd ex: i=100 which then x=i in char datatype that is char x variable is assigned with i=100 which is not byond range of char data type..therefor no truncation in this example we can find.

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More C Interview Questions

What is an expression?

0 Answers  


how to convert binary to decimal and decimal to binary in C lanaguage

7 Answers   BPO, Far East Promotions, IBM, RBS,


How can I increase the allowable number of simultaneously open files?

1 Answers   ABC,


Explain what is the difference between declaring a variable and defining a variable?

1 Answers  


Explain the use of fflush() function?

0 Answers  






What are the different types of pointers used in c language?

0 Answers  


What is an lvalue?

0 Answers  


What is the difference between array_name and &array_name?

0 Answers  


write a programme that inputs a number by user and gives its multiplication table.

2 Answers  


how does a general function , that accepts an array as a parameter, "knows" the size of the array ? How should it define it parameters list ?

0 Answers  


In C programming, what command or code can be used to determine if a number of odd or even?

0 Answers  


1. main() { printf("%d",printf("HelloSoft")); } Output?

3 Answers   HCL,


Categories