Enter your email id to get regular update free
Login
Your Email
Pasword

Type conversion and type casting on #C (module 12)

In this section we will discuss on the types of type casting and implicit and explicit type conversion in #C

This is the 12th module on learning C with us. Earlier we discussed on the basic introduction and structure of C, preprocessor it's features, intermediate and executable codes. compilation and execution process of a C program. And keywords and identifiers, data types, variables and constants, scope of variables, operators and expressions in C.
In this section we will discuss on the types of type casting and implicit and explicit type conversion in #C program.

Type conversion :- 
In an expression that involves two different datatypes, such as multiplying an integer and a floating point number to perform these evaluations, one of the types must be converted.

We have two types of conversions :-
1. Implicit type conversion.
2. Explicit type conversion.

Implicit type conversion :-
When the types of the two operands in a binary expression are different automatically converts one type to another. This is known as Implicit type conversion.

main()
{ int a , b, c;
  a=5;b=2;
  c=a/b;
  printf("%d",c);
}
Explicit type conversion :-
Explicit type conversion uses the unary cast operator, to convert data from one type to another. To cast data from one type to another, we specify the new type in parentheses before the value we want converted.
main() 
{ int a , b;
   float c; 
   a=5;
   b=2; 
   c=(float)a/b; 
   printf("%d",c); 
}
In next module we will continue the next module on input and output functions i.e module 13. For more information please be updated with us as we provide all the modules and cover all the topics regarding #C. Only on Www.newsandstory.com
Type casting
type conversion
Implicit type
explicit type
Programming
coding
learning
#c
Dalpat I
Content writer
Total 349 views