- Implicit type cast
- Explicit type cast
what you think, what will be data type of i?
Surprise, let's explain to me, it is a common type cast mistake, look at per=total/300*100; statement. In this statement first of all total/300 will be solve so total(240) and 300 are int hence 240/300 will be produce a float value so result is 0.000000. These mistake may me solved by three ways as:
1. We mention type cast in above program as:
/*demonstration of type casting*/
2. We used total as float variable.
3. we convert int to float to the 300 by adding decimal portion.