Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is anagram in c?

979


Explain why can’t constant values be used to define an array’s initial size?

1398


a program that can input number of records and can view it again the record

1959


Write a program for Overriding.

1210


How do I read the arrow keys? What about function keys?

1145


Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?

3562


What is the difference between functions abs() and fabs()?

1207


Explain how can I prevent another program from modifying part of a file that I am modifying?

1140


What are the advantages of union?

1117


What is p in text message?

1037


What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.

4332


Explain 'bus error'?

1164


if p is a string contained in a string?

1889


Which control loop is recommended if you have to execute set of statements for fixed number of times?

1405


Write a program to use switch statement.

1182