Pages

Thursday, July 04, 2013

Write a program that print the Name of data types, Bit Width and Bit Width use in C++

Name of data types, Bit Width and Bit Width

INPUT:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
      #include <iostream.h>
      #include <conio.h>
      int main()
      {       
      cout << " Type               Typical Bit Width            Typical Bit Width   \n";
      cout << " char                     1byte             -127 to 127 or 0 to 255    \n";
      cout << " unsigned char            1byte                  0 to 255                   \n";
      cout << " signed char              1byte             -127 to 127                \n";
      cout << " int                      4bytes              -2147483648 to 2147483647  \n";
      cout << " unsigned int             4bytes              0 to 4294967295            \n";
      cout << " signed int               4bytes               -2147483648 to 2147483647   \n";
      cout << " short int                2bytes              -32768 to 32767             \n";
      cout << " unsigned short int       Range              0 to 65,535                 \n";
      cout << " signed short int         Range              -32768 to 32767             \n";
      cout << " long int                 4bytes           -2,147,483,647 to 2,147,483,647\n";
      cout << " signed long int          4bytes              same as long int                   \n";
      cout << " unsigned long int        4bytes             0 to 4,294,967,295               \n";
      cout << " float                    4bytes            +/- 3.4e +/- 38 (~7 digits)        \n";
      cout << " double                   8bytes            +/- 1.7e +/- 308 (~15 digits)      \n";
      cout << " long double              8bytes            +/- 1.7e +/- 308 (~15 digits)      \n";
      getch(); 
      return 0;
                } //main

OUTPUT:

   Type               Typical Bit Width                 Typical Bit Width 
 char                     1byte             -127 to 127 or 0 to 255
 unsigned char            1byte                       0 to 255           
 signed char              1byte                    -127 to 127            
 int                      4bytes            -2147483648 to 2147483647
 unsigned int             4bytes                0 to 4294967295          
 signed int               4bytes            -2147483648 to 2147483647  
 short int                2bytes                 -32768 to 32767    
 unsigned short int       Range                       0 to 65,535           
 signed short int         Range                  -32768 to 32767     
 long int                 4bytes         -2,147,483,647 to 2,147,483,647
 signed long int          4bytes              same as long int
 unsigned long int        4bytes                     0 to 4,294,967,295   
 float                    4bytes             +/- 3.4e +/- 38 (~7 digits)      
 double                   8bytes             +/- 1.7e +/- 308 (~15 digits)    
 long double              8bytes             +/- 1.7e +/- 308 (~15 digits) 


No comments:

Post a Comment