Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Type casting in C

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 42
    Comment on it

    Type casting is to change the  data type of a variable according to programming need.

     

    Type casting is done to assign values to dissimilar data type or to perform manipulation over dissimilar data type.

     

    Usual Arithmetic Conversion

     

     

    Type casting is of two kind :

     

    First is performed by the system itself known as internal typecating.

    Second is performed by the programmer known as explicit typecasting.

     

     

    #include <stdio.h>
    
    main() {
    
       int sum = 17, count = 5;
       double mean;
    
       mean = (double) sum / count;
       printf("Value of mean : %f\n", mean );
    
    }

     

    Integer Promotion

    Integer promotion is the process in which value of  "smaller" than int or unsigned int are converted either to int or unsigned int.

     

    #include <stdio.h>
    
    main() {
    
       int  i = 17;
       char c = 'c'; /* ascii value is 99 */
       int sum;
    
       sum = i + c;
       printf("Value of sum : %d\n", sum );
    
    }

     

    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: