Warning: Undefined variable $user in /home/geekint/public_html/learn/wp-content/plugins/google-plus-authorship/google-plus-authorhip.php on line 28
Warning: Attempt to read property "ID" on null in /home/geekint/public_html/learn/wp-content/plugins/google-plus-authorship/google-plus-authorhip.php on line 28
Deprecated: Function get_bloginfo was called with an argument that is deprecated since version 2.2.0! The
home
option is deprecated for the family of bloginfo()
functions. Use the url
option instead. in /home/geekint/public_html/learn/wp-includes/functions.php on line 6114Deprecated: Function get_the_author_ID is deprecated since version 2.8.0! Use get_the_author_meta('ID') instead. in /home/geekint/public_html/learn/wp-includes/functions.php on line 6114
Warning: Undefined variable $customprofilefield in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 66
Deprecated: Function get_the_author_description is deprecated since version 2.8.0! Use get_the_author_meta('description') instead. in /home/geekint/public_html/learn/wp-includes/functions.php on line 6114
Warning: Undefined variable $display_author_email in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 152
Warning: Undefined variable $display_google_profile in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 152
Warning: Undefined variable $display_facebook_profile in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 152
Warning: Undefined variable $display_twitter_profile in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 152
Warning: Undefined variable $display_youtube_profile in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 152
Warning: Undefined variable $display_linkedin_profile in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 152
Warning: Undefined variable $display_pinterest_profile in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 152
How typecasting plays an important role in C
C allows programmers to perform typecasting by placing the type name in parentheses and placing this in front of the value.
For instance
main()
{
float a;
a = (float)5 / 3;
}
gives result as 1.666666 . This is because the integer 5 is converted to floating point value before division and the operation between float and integer results in float.
From the above it is clear that the usage of typecasting is to make a variable of one type, act like another type for one single operation. So by using this ability of typecasting it is possible for create ASCII characters by typecasting integer to its character equivalent.
Typecasting is also used in arithmetic operation to get correct result. This is very much needed in case of division when integer gets divided and the remainder is omitted. In order to get correct precision value, one can make use of typecast as shown in example above. Another use of the typecasting is shown in example below
For instance:
main()
{
int a = 5000, b = 7000 ;
long int c = a * b ;
}
Here two integers are multiplied and the result is truncated and stored in variable c of type long int. But this would not fetch correct result for all. To get a more desired output the code is written as
long int c = (long int) a * b;
Though typecast has so many uses one must take care about its usage since using typecast in wrong places may cause loss of data like for instance truncating a float when typecasting to an int.