Download - Time to Put on your thinking Hats
![Page 1: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/1.jpg)
![Page 2: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/2.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){int a=32767;printf(“%d”, a);
}
2
![Page 3: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/3.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){int a=32769;printf(“%d”, a);
}
3
![Page 4: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/4.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){int a=1232.5;printf(“%d”, a);
}
4
![Page 5: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/5.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){int a=-32779.205;printf(“%d”, a);
}
5
![Page 6: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/6.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){
float a=-3279.205;printf(“%d”, a);
}
6
![Page 7: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/7.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){
int a=-3279.205;printf(“%f”, a);
}
7
![Page 8: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/8.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){
float a=-32779.205;printf(“%f”, a);
}
8
![Page 9: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/9.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){
float a=-32779.205;printf(“%.1f”, a);
}
9
![Page 10: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/10.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){float a=69;printf(“%f”, a);
}
10
![Page 11: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/11.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){int a,b,c;a=5;b=2;c=a/b;printf(“%d”, c);
}11
![Page 12: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/12.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){
int a,b;float c;a=5;b=2;c=a/b;printf(“%f”, c);
}12
![Page 13: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/13.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){float a,b,c;a=5;b=2;c=a/b;printf(“%f”, c);
}
13
![Page 14: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/14.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){
int a,b;float c;a=5;b=2;c=(float)a/b;printf(“%f”, c);
}14
![Page 15: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/15.jpg)
Compiled By Nidhi Poddar @ VITA
A-Z 65-90 a-z 97-122 0-9 48-57 Special symbols:
0-4758-6491-96123-254
15
![Page 16: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/16.jpg)
Compiled By Nidhi Poddar @ VITA
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);
}16
![Page 17: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/17.jpg)
Compiled By Nidhi Poddar @ VITA 17
![Page 18: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/18.jpg)
Compiled By Nidhi Poddar @ VITA
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
![Page 19: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/19.jpg)
Compiled By Nidhi Poddar @ VITA
#include<stdio.h>void main(){printf("%d",5+3*6/2-5);}
9
5+18/2-5 // division has higher precedence then + and -5+9-5 //+ , - has same precedence so check associativity ie. L to r9
19
![Page 20: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/20.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){
int a,b,c;a=5;b=2;c=a;a=b;b=c;printf(“%d,%d”,a,b);
}
21
![Page 21: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/21.jpg)
Compiled By Nidhi Poddar @ VITA
Suppose we print c over here what would be its value?
5, as it copy paste the value and does not cut paste the values
22
![Page 22: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/22.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){
int a,b;a=5;b=2;a=a+b;b=a-b;a=a-b;printf(“%d,%d”,a,b);
}
23
![Page 23: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/23.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){
int a,b;a=5;b=2;a=a*b;?=a/b;?=a/b;printf(\n“%d,%d”,a,b);
}
24
![Page 24: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/24.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){
int a,b;a=5;b=2;a=a^b;b=a^b;a=a^b;printf(“\n%d,%d”,a,b);
}
25
![Page 25: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/25.jpg)
Compiled By Nidhi Poddar @ VITA
a=5 101 b=6 110 a^b=3 011
a=3 011 b=6 110 a^b=5 101
a=3 011 b=5 101 a^b=6 110
26
![Page 26: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/26.jpg)
b = (a*a)/a + (a=b) - a;
a^=b^=a^=b;
27
![Page 27: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/27.jpg)
28
![Page 28: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/28.jpg)
29
![Page 29: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/29.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){
char s=5;s++;printf(“%d”,s);printf(“%d”,s++);printf(“%d”,s);printf(“%d”,++s);printf(“%d”,s);
}
30
![Page 30: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/30.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){
int s=5;s++;printf(“%d”,s);printf(“%d”,s--);printf(“%d”,s);printf(“%d”,--s);printf(“%d”,s);
}
31
![Page 31: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/31.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){
char s=5;printf(“%d”,s+++s);
}
What would the compiler read it as?a++ +a
Or a+ ++a
Note: Post increment has higher precedence than pre increment
32
![Page 32: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/32.jpg)
Compiled By Nidhi Poddar @ VITA
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++++);
33
![Page 33: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/33.jpg)
Compiled By Nidhi Poddar @ VITA
void main(){
char s=5;printf(“%d%d%d%d”,++s,++s,s++,++s);printf(“\n%d”,s);
}
Note: Post increment has higher precedence than pre increment, but here associativety is Right to Left
34
![Page 34: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/34.jpg)
Compiled By Nidhi Poddar @ VITA
1 km=1000m 1m=100cm I inch=2.54 cm 1 feet=12inch
35
![Page 35: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/35.jpg)
Compiled By Nidhi Poddar @ VITA
Bitwise Operators3^2&~1
36
![Page 36: Time to Put on your thinking Hats](https://reader034.vdocument.in/reader034/viewer/2022051516/568143a9550346895db03012/html5/thumbnails/36.jpg)
37