250 likes | 326 Views
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); }.
E N D
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); } 1233 1232
What would be the output void main() { int a=-32779.205; printf(“%d”, a); } 32757 Subtract 11-1=10 to 32767
What would be the output void main() { float a=-3279.205; printf(“%d”, a); } -3279
What would be the output void main() { int a=-3279.205; printf(“%f”, a); } -3279.000000
What would be the output void main() { float a=-32779.205; printf(“%f”, a); } -32779.205000
What would be the output void main() { float a=-32779.205; printf(“%.1f”, a); } -32779.2
What would be the output void main() { float a=69; printf(“%f”, a); } 69.000000
What would be the output and how many bytes will it occupy void main() { int a,b,c; a=5; b=2; c=a/b; printf(“%d”, c); } 2 & 6 bytes Size of int*3
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
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
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
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
£ • 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
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);
Associativity and precedence 9 #include<stdio.h> void main() { printf("%d",5+3*6/2-5); }
What would be the output void main() { printf(“%d”, printf(“vita”)); } vita4
++ 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;
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
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
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++++);
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
What would be the output Bitwise Operators 3^2&~1 1