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 has to put when we are inserting as assembly language code into the C code? or When we are inserting as assembly language code into the C code we have to insert one thing at the start and of the assembly language. What are they?

2 Answers  


Where static variables are stored in memory in c?

0 Answers  


what is the stackpointer

2 Answers  


Write a program to print “hello world” without using semicolon?

0 Answers  


what will the following program do? void main() { int i; char a[]="String"; char *p="New Sring"; char *Temp; Temp=a; a=malloc(strlen(p) + 1); strcpy(a,p); //Line no:9// p = malloc(strlen(Temp) + 1); strcpy(p,Temp); printf("(%s, %s)",a,p); free(p); free(a); } //Line no 15// a) Swap contents of p & a and print:(New string, string) b) Generate compilation error in line number 8 c) Generate compilation error in line number 5 d) Generate compilation error in line number 7 e) Generate compilation error in line number 1

1 Answers   IBM,


Why c is a mother language?

0 Answers  


What is the output for the program given below typedef enum grade{GOOD,BAD,WORST,}BAD; main() { BAD g1; g1=1; printf("%d",g1); }

4 Answers   ADITI,


What is identifier in c?

0 Answers  


Is c weakly typed?

0 Answers  


what is constant pointer?

3 Answers  


What is a void pointer? When is a void pointer used?

0 Answers   Aspire, Infogain,


When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.

0 Answers   HCL,


Categories