Program Simple Type Promotion


    #include<iostream.h>
    int main( )
    {
          // prints promoted values of 65 from char to double
          char c ='A' ;         cout << "char c  =  " << c << "\n" ; 
          short k = c ;           cout << " short k  =  " << k << "\n" ;
          int m = k ;              cout << "int m  =  " << m << "\n" ;
          long n = m ;           cout << "long n  =  " << n << "\n" ; 
          float x = m ;           cout << "float x  =  " << x << "\n" ; 
      double y = x ;         cout << "double y  =  " << y << "\n" ;
      return 0;
     }

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|