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 / 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 |
What is your favorite subject?
1 Answers Ericsson, Invendis, Tech Mahindra,
How many bytes is a struct in c?
Result of the following program is main() { int i=0; for(i=0;i<20;i++) { switch(i) case 0:i+=5; case 1:i+=2; case 5:i+=5; default i+=4; break;} printf("%d,",i); } } a)0,5,9,13,17 b)5,9,13,17 c)12,17,22 d)16,21 e)syntax error
How can I call fortran?
1,4,8,13,21,30,36,45,54,63,73,?,?.
10 Answers AMB, Franklin Templeton,
Difference between macros and inline functions? Can a function be forced as inline?
0 Answers HAL, Honeywell, Zomato,
can any one provide me the notes of data structure for ignou cs-62 paper
main() { char x; while(x=0;x<=255;x++) printf("\nAscii value %d Charater %c",x,x); }
why do we use pointer instead directly acessing the data?
What is the difference between constant pointer and constant variable?
Explain main function in c?
how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions