1 / 25

Time to Put on your thinking Hats

Time to Put on your thinking Hats. What would be the output. void main() { int a=32767; printf (“%d”, a); }. 32767. What would be the output. void main() { int a=32769; printf (“%d”, a); }. -32767. What would be the output. void main() { int a=1232.5; printf (“%d”, a); }.

farica
Download Presentation

Time to Put on your thinking Hats

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Time toPut on your thinking Hats

  2. What would be the output void main() { int a=32767; printf(“%d”, a); } 32767

  3. What would be the output void main() { int a=32769; printf(“%d”, a); } -32767

  4. What would be the output void main() { int a=1232.5; printf(“%d”, a); } 1233 1232

  5. What would be the output void main() { int a=-32779.205; printf(“%d”, a); } 32757 Subtract 11-1=10 to 32767

  6. What would be the output void main() { float a=-3279.205; printf(“%d”, a); } -3279

  7. What would be the output void main() { int a=-3279.205; printf(“%f”, a); } -3279.000000

  8. What would be the output void main() { float a=-32779.205; printf(“%f”, a); } -32779.205000

  9. What would be the output void main() { float a=-32779.205; printf(“%.1f”, a); } -32779.2

  10. What would be the output void main() { float a=69; printf(“%f”, a); } 69.000000

  11. What would be the output and how many bytes will it occupy void main() { inta,b,c; a=5; b=2; c=a/b; printf(“%d”, c); } 2 & 6 bytes Size of int*3

  12. What would be the output and how many bytes will it occupy void main() { inta,b; float c; a=5; b=2; c=a/b; printf(“%f”, c); } 2.000000 & 8 bytes Size of int*2 +Size of float

  13. What would be the output and how many bytes will it occupy void main() { float a,b,c; a=5; b=2; c=a/b; printf(“%f”, c); } 2.500000 & 12 bytes Size of float*3

  14. What would be the output and how many bytes will it occupy void main() { inta,b; float c; a=5; b=2; c=(float)a/b; printf(“%f”, c); } 2.500000 &8 bytes Size of int*2 +Size of float

  15. What would be the output void main() { char s=65; char ch=‘A’; char st=‘25’; printf(“%d”,ch); printf(“%c”,ch); printf(“%d”,s); printf(“%c”,s); printf(“%c”,st); printf(“%d”,st); } 65 A 65 A 2 50

  16. £ • Try some of these: printf(“%c”,-100); printf(“%c”,-128); printf(“%c”,-130); printf(“%c”,100); printf(“%d”,-10); printf(“%x”,1>>4); printf(“%x”,16); Ç ~ d -10 ffff 10

  17. Try some of these: printf(“%d”,-100); printf(“%.2f”,128); printf(“%f”,-130); printf(“%c”,91); printf(“%d”,34342); printf(“%x”,1004); printf(“%x”,16);

  18. Associativity and precedence 9 #include<stdio.h> void main() { printf("%d",5+3*6/2-5); }

  19. What would be the output void main() { printf(“%d”, printf(“vita”)); } vita4

  20. ++ is increment by 1a++ is post increment++a is pre incrementa=a+1;-- is decrement by 1a-- is post decrement--a is pre decrementa=a-1;

  21. What would be the output void main() { char s=5; s++; printf(“%d”,s); printf(“%d”,s++); printf(“%d”,s); printf(“%d”,++s); printf(“%d”,s); } 6 6 7 8 8

  22. What would be the output void main() { int s=5; s++; printf(“%d”,s); printf(“%d”,s--); printf(“%d”,s); printf(“%d”,--s); printf(“%d”,s); } 6 6 5 4 4

  23. Please try Some of these • printf(“%d”, s++s); • printf(“%d”, s++++s); • printf(“%d”, s+++++s); • printf(“%d”, s++ + ++s); • printf(“%d”,++s+++s); • printf(“%d”,++s+++s++); • printf(“%d”, s+s++); • printf(“%d”, s+s++++);

  24. What would be the output void main() { char s=5; printf(“%d%d%d%d”,++s,++s,s++,++s); printf(“\n%d”,s); } 9 8 6 6 9

  25. What would be the output Bitwise Operators 3^2&~1 1

More Related