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.
Answer Posted / 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 View All Answers
hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell
What are integer variable, floating-point variable and character variable?
Explain the use of 'auto' keyword in c programming?
How can I manipulate strings of multibyte characters?
What is c language and why we use it?
Whats s or c mean?
‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.
What does p mean in physics?
What is pointers in c with example?
how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12
How are pointers declared in c?
Why is it usually a bad idea to use gets()? Suggest a workaround.
Why we use conio h in c?
Explain continue keyword in c
find out largest elemant of diagonalmatrix