Program to demonstrate type conversion in C



Type conversionis that which converts one data type into another. E.g. converting a int into float, converting a float into double, etc. The type conversion is that which automaticallyconverts one data type into another.
            When a user converts one data type into another then it is called as the type casting. Remember the type Conversion is performed by the compiler but a casting is done by the user. E.g.converting a float into int.


            #include <stdio.h>
            #include <conio.h>
            void main()
             {
                        double dValue = 3; // implicit conversion to double value 3.000000
                        int nValue = 3.14156; // implicit conversion to integer value 3
                        clrscr();
                        printf("dValue = %f", dValue);
                        printf("\nnValue = %d", nValue);
                        getch();
            }


Post a Comment