Operators and Expressions II-63
16. Find the size of bytes for integer, character and long integers.
#include <stdio.h>
#include <conio.h>
void main()
{
char x='a';
int y=2;
long int z=23456;
float p=2.345;
double q=12e10;
clrscr();
printf("
size of a character(x)=%d byte",sizeof(x));
printf("
size of an integer(y)=%d bytes",sizeof(y));
printf("
size of long integer(z)=%d bytes",sizeof(z));
printf("
size of float(p)=%d bytes",sizeof(p));
printf("
size of double float (q)=%d bytes",sizeof(q));
printf("
Address of x=%u y=%u z=%u p=%u q=%u",&x,&y,&z,&p,&q);
getche();
}
OUTPUT:
size of a character(x)= 1 byte
size of an integer(y)= 2 bytes
size of long integer(z)= 4 bytes
size of float(p)= 4 bytes
size of double float (q)= 8 bytes
Address of x = 65479 y = 65480 z = 65482 p = 65486 q = 65490
Examples on bitwise operators.
17. Left and right shift
void main()
{
int x=2,y=16,z;
clrscr();
x<<=2,y>>=1;
x&=y;
z=y|x;
printf("%d %d ",x,z);
getche();
}
OUTPUT:
8 8
M03_ITL-ESL4791_02_SE_C03.indd 63 12/22/2012 5:00:08 PM