"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Monday, April 26, 2010

WAP to calculate the size of integer, character, float , double datatype


#include<iostream.h>
#include<conio.h>


void main()
{
clrscr();
cout<< " \nSize of character = " << sizeof(char);
cout<< " \nSize of integer = " << sizeof(int);
cout<< "\n Size of float = " << sizeof(float);
cout<< "\n Size of double = " << sizeof(double);
getch();
}


ALTERNATIVELY,

#include(iostream.h)
#include(conio.h)

void main()
{
clrscr(); 
int n;
float f;
char c;
double d;
cout<< " \nSize of character= " << sizeof(c);
cout<< " \nSize of integer = " << sizeof(n);
cout<< "\n Size of float = " << sizeof(f);
cout<< "\n Size of double = " << sizeof(d);
getch();
}


No comments:

Post a Comment

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.