Pages

Saturday, July 06, 2013

Write a program of use the operator (size of) in C++

Use the operator (size of)

Source Code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
    #include <iostream>
    #include <conio.h>
    using namespace std;
    int main()
    {
   cout << "Size of char : " << sizeof(char) << endl;
   cout << "Size of int : " << sizeof(int) << endl;
   cout << "Size of short int : " << sizeof(short int) << endl;
   cout << "Size of long int : " << sizeof(long int) << endl;
   cout << "Size of float : " << sizeof(float) << endl;
   cout << "Size of double : " << sizeof(double) << endl;
   getch ();
   return 0;
                 }//main

Output:

Size of char : 1
Size of int : 4
Size of short int : 2
Size of long int : 4
Size of float : 4
Size of double : 8


No comments:

Post a Comment