0% found this document useful (0 votes)
10 views36 pages

Test Your C

Uploaded by

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

Test Your C

Uploaded by

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

void main()

{
int a=32767;
printf(“%d”, a);
}

Compiled By Nidhi Poddar @ VITA 2


void main()
{
int a=32769;
printf(“%d”, a);
}

Compiled By Nidhi Poddar @ VITA 3


void main()
{
int a=1232.5;
printf(“%d”, a);
}

Compiled By Nidhi Poddar @ VITA 4


void main()
{
int a=-32779.205;
printf(“%d”, a);
}

Compiled By Nidhi Poddar @ VITA 5


void main()
{
float a=-3279.205;
printf(“%d”, a);
}

Compiled By Nidhi Poddar @ VITA 6


void main()
{
int a=-3279.205;
printf(“%f”, a);
}

Compiled By Nidhi Poddar @ VITA 7


void main()
{
float a=-32779.205;
printf(“%f”, a);
}

Compiled By Nidhi Poddar @ VITA 8


void main()
{
float a=-32779.205;
printf(“%.1f”, a);
}

Compiled By Nidhi Poddar @ VITA 9


void main()
{
float a=69;
printf(“%f”, a);
}

Compiled By Nidhi Poddar @ VITA 10


void main()
{
int a,b,c;
a=5;
b=2;
c=a/b;
printf(“%d”, c);
}
Compiled By Nidhi Poddar @ VITA 11
void main()
{
int a,b;
float c;
a=5;
b=2;
c=a/b;
printf(“%f”, c);
}
Compiled By Nidhi Poddar @ VITA 12
void main()
{
float a,b,c;
a=5;
b=2;
c=a/b;
printf(“%f”, c);
}
Compiled By Nidhi Poddar @ VITA 13
void main()
{
int a,b;
float c;
a=5;
b=2;
c=(float)a/b;
printf(“%f”, c);
}
Compiled By Nidhi Poddar @ VITA 14
 A-Z 65-90
 a-z 97-122
 0-9 48-57
 Special symbols:
 0-47
 58-64

 91-96

 123-254

Compiled By Nidhi Poddar @ VITA 15


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);
}
Compiled By Nidhi Poddar @ VITA 16
Compiled By Nidhi Poddar @ VITA 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);
Compiled By Nidhi Poddar @ VITA 18
#include<stdio.h>
void main()
{ 9
printf("%d",5+3*6/2-5);
}

5+18/2-5 // division has higher precedence then + and -


5+9-5 //+ , - has same precedence so check associativity
ie. L to r
9

Compiled By Nidhi Poddar @ VITA 19


void main()
{
int a,b,c;
a=5;
b=2;
c=a;
a=b;
b=c;
printf(“%d,%d”,a,b);
}
Compiled By Nidhi Poddar @ VITA 21
 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

Compiled By Nidhi Poddar @ VITA 22


void main()
{
int a,b;
a=5;
b=2;
a=a+b;
b=a-b;
a=a-b;
printf(“%d,%d”,a,b);
}
Compiled By Nidhi Poddar @ VITA 23
void main()
{
int a,b;
a=5;
b=2;
a=a*b;
?=a/b;
?=a/b;
printf(\n“%d,%d”,a,b);
}
Compiled By Nidhi Poddar @ VITA 24
void main()
{
int a,b;
a=5;
b=2;
a=a^b;
b=a^b;
a=a^b;
printf(“\n%d,%d”,a,b);
}
Compiled By Nidhi Poddar @ VITA 25
 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
Compiled By Nidhi Poddar @ VITA 26
b = (a*a)/a + (a=b) - a;

a^=b^=a^=b;

27
28
29
void main()
{
char s=5;
s++;
printf(“%d”,s);
printf(“%d”,s++);
printf(“%d”,s);
printf(“%d”,++s);
printf(“%d”,s);

}
Compiled By Nidhi Poddar @ VITA 30
void main()
{
int s=5;
s++;
printf(“%d”,s);
printf(“%d”,s--);
printf(“%d”,s);
printf(“%d”,--s);
printf(“%d”,s);

}
Compiled By Nidhi Poddar @ VITA 31
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

Compiled By Nidhi Poddar @ VITA 32


 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++++);

Compiled By Nidhi Poddar @ VITA 33


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

Compiled By Nidhi Poddar @ VITA 34


 1 km=1000m
 1m=100cm
 I inch=2.54 cm
 1 feet=12inch

Compiled By Nidhi Poddar @ VITA 35


Bitwise Operators
3^2&~1

Compiled By Nidhi Poddar @ VITA 36


37

You might also like