Sunday, 31 July 2016

PROGRAM TO FIND THE SIZE OF VARIOUS DATA TYPES

# include<iostream.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;
    cout<<"size of wchar_t:"<<sizeof(wchar_t)<<endl;
    return 0;
}

In this example :
1)       endl       = endl is use to insert a new line character after every line .
2) << operator= this is being used to pass multiple values out to the screen .
3)     sizeof       = this is used to get size of various data types.

*when you execute the above program you will get the following  result.
 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
 size of wchar_t : 4 

No comments:

Post a Comment