0% found this document useful (0 votes)
25 views

Assignment2 Operators

Uploaded by

Arun Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Assignment2 Operators

Uploaded by

Arun Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment-2 (operators).

1. What is binary equivalent of

i)char ch=’5’; ii) short int s = -520; iii) int i = -2; iv) float f=45.6 ; v)double d= -45.6;

2. What is the range of char, short int, int , long int, float.

3. main( ) { unsigned char a;

a = 0xFF + 1;
printf("%d", a); }

4. main() { int x=10, y=20, z=5, i;


i =x<y<z;
printf("%d", i); }

5. main(){ unsigned int x=022,y=0x22, z=022; printf(“%d”,x+y+z); }

6. main() { int a = 123, b = 456;

a ^= b ^= a ^= b;
printf(" %d %d" , a,b); }

7. List 6 number of unary operators.

8. main() { int a=10,b;


b=a>=5?100:200;
printf("%d",b); }

9. main() { printf("%d\n", -1<<4);


printf(“ %d\n”, -1 >>2);
printf(“%x\n”, 1<<10);
printf(“%x\n”, 0xFF<<4);
printf(“%o\n”, 034<<2); }

10. main() { printf("%d\n", 1<<4>>4);


printf(“%d\n”, 1<<31>>30); }

11. main( ) { double f = 33.3; int x;


x= ( f > 33.3) + (f = = 33.3); printf("%d",x); }

12. main() { unsigned int res;

res = (64 >>(2+1-2)) & (~(1<<2));


printf("%d", res); }

13. main() { int z,x=5,y=-10,a=4,b=2;

z=x++ - --y * --b / a;

printf("%d ",z); }
14. main(){ printf(“%lu\n”,sizeof(‘\n’));

printf(“%lu\n”,sizeof(“5”));

printf(“%lu\n”,sizeof(5.0));

printf(“%lu\n”,sizeof(23.4f));

printf(“%lu\n”,sizeof(“23.4f”)); }

15. main() { printf(“%d\n”,(0x11>11) && (11>011));

printf(“%d\n”, sizeof(-1) > 10);

printf(“%d\n”, 23.0>23);

16. main() { int a=-1,b=0, c=5;

char ch=’a’;

printf(“%d\n”, (ch>=97)&&(ch<=122));

printf(“%d\n”,(a==0) || (b==0) ||(c==0));

printf(“%d\n”, (a<b)&&(b<c));

17. main(){ printf(“%d\n”,-1&3456);

printf(“%d\n”, -1| 456);

printf(“%d\n”, -1 ^ 789);

printf(“%d\n”, 0&789);

printf(“%d\n”,0&234);

18. main(){ int bitMask=1;

printf(“%d\n”, 50 & bitMask);

bitMask=32;

printf(“%d\n”,50 & bitMask);

printf(“%d\n”,60 & bitMask);


printf(“%d\n”,70 & bitMask);

bitMask=512;

printf(“%d\n”,525&bitMask); }

19. main(){ int var=50,bit=3;

printf(“%d\n”,var&(1<<3));

printf(“%d\n”,var&(1<<4));

printf(“%d\n”,var&(1<<5)); }

20. main(){ int a=2,b=4,c=5;

a+=b*=c-=10;

printf(“%d %d %d\n”,a,b,c); }

You might also like