Monday, January 5, 2009

c programming language question with Outputs

(1)void main()
{
int i='-'-'-';
int a;
clrscr();
a=sizeof(i++,++i,1.1);
printf(" a= %d i= %d",a,i);
getch();
}


output : a=0 a=8

(2)

void main()
{
unsigned int i=-1;
int j=-1;
float b,c;
clrscr();
b=i+5.5;
c=j+5.5;
printf("%.0f %.0e\n",b,c);
printf("%u\n",i*-1);
printf("%u\n",-i*-1);
getch();
}


output: 65540 4e+00
1
65535


(3)

void main()
{
unsigned char a=-13;
int b;
clrscr();
b=~(a^a);
printf("%x %X\n",b);
getch();
}


output:ffff FFFF
(4)

void main()
{
struct xxx {
int z:3;
int x:3;
}x;
x.z=4;
x.x=-4;
clrscr();
printf("%d %d",x.z,x.x);
getch();
}


output: -4 -4
(5)

void main()
{
clrscr();
printf("%o",sizeof(""));
getch();
}


output: 1

No comments:

Blog List