compiled by nidhi poddar @ vita void main() { int a=32767; printf(“%d”, a); } 2
TRANSCRIPT
Compiled By Nidhi Poddar @ VITA
void main(){int a=32767;printf(“%d”, a);
}
2
Compiled By Nidhi Poddar @ VITA
void main(){int a=32769;printf(“%d”, a);
}
3
Compiled By Nidhi Poddar @ VITA
void main(){int a=1232.5;printf(“%d”, a);
}
4
Compiled By Nidhi Poddar @ VITA
void main(){int a=-32779.205;printf(“%d”, a);
}
5
Compiled By Nidhi Poddar @ VITA
void main(){
float a=-3279.205;printf(“%d”, a);
}
6
Compiled By Nidhi Poddar @ VITA
void main(){
int a=-3279.205;printf(“%f”, a);
}
7
Compiled By Nidhi Poddar @ VITA
void main(){
float a=-32779.205;printf(“%f”, a);
}
8
Compiled By Nidhi Poddar @ VITA
void main(){
float a=-32779.205;printf(“%.1f”, a);
}
9
Compiled By Nidhi Poddar @ VITA
void main(){float a=69;printf(“%f”, a);
}
10
Compiled By Nidhi Poddar @ VITA
void main(){int a,b,c;a=5;b=2;c=a/b;printf(“%d”, c);
}11
Compiled By Nidhi Poddar @ VITA
void main(){
int a,b;float c;a=5;b=2;c=a/b;printf(“%f”, c);
}12
Compiled By Nidhi Poddar @ VITA
void main(){float a,b,c;a=5;b=2;c=a/b;printf(“%f”, c);
}
13
Compiled By Nidhi Poddar @ VITA
void main(){
int a,b;float c;a=5;b=2;c=(float)a/b;printf(“%f”, c);
}14
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
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
Compiled By Nidhi Poddar @ VITA 17
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
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
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
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
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
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
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
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
b = (a*a)/a + (a=b) - a;
a^=b^=a^=b;
27
28
29
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
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
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
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
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
Compiled By Nidhi Poddar @ VITA
1 km=1000m 1m=100cm I inch=2.54 cm 1 feet=12inch
35
Compiled By Nidhi Poddar @ VITA
Bitwise Operators3^2&~1
36
37