25
TIME TO PUT ON YOUR THINKING HATS

Time to Put on your thinking Hats

  • Upload
    farica

  • View
    26

  • Download
    4

Embed Size (px)

DESCRIPTION

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); }. - PowerPoint PPT Presentation

Citation preview

Page 1: Time to Put on your  thinking Hats

TIME TOPUT ON YOUR

THINKING HATS

Page 2: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUT

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

}

32767

Page 3: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUT

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

}

-3276

7

Page 4: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUT

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

}12331232

Page 5: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUT

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

}3275

7

Subtract 11-1=10 to 32767

Page 6: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUT

void main(){

float a=-3279.205;printf(“%d”, a);

}-3279

Page 7: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUT

void main(){

int a=-3279.205;printf(“%f”, a);

} -3279.00000

0

Page 8: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUT

void main(){

float a=-32779.205;printf(“%f”, a);

}-

32779.205000

Page 9: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUT

void main(){

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

}-32779.2

Page 10: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUT

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

}69.0000

00

Page 11: Time to Put on your  thinking Hats

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 bytesSize of int*3

Page 12: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUT AND HOW MANY BYTES WILL IT OCCUPY

void main(){

int a,b;float c;a=5;b=2;c=a/b;printf(“%f”, c);

}

2.000000& 8

bytesSize of int*2 +Size of float

Page 13: Time to Put on your  thinking Hats

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 bytesSize of float*3

Page 14: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUT AND HOW MANY BYTES WILL IT OCCUPY

void main(){

int a,b;float c;a=5;b=2;c=(float)a/b;printf(“%f”, c);

}

2.500000&8 bytesSize of int*2 +Size of float

Page 15: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUTvoid 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);

}

65A65A250

Page 16: Time to Put on your  thinking Hats

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

-10ffff

10

Page 17: Time to Put on your  thinking Hats

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

Page 18: Time to Put on your  thinking Hats

ASSOCIATIVITY AND PRECEDENCE

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

9

Page 19: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUT

void main(){printf(“%d”, printf(“vita”));

} vita4

Page 20: Time to Put on your  thinking Hats

++ is increment by 1

a++ is post increment++a is pre incrementa=a+1;

-- is decrement by 1

a-- is post decrement--a is pre decrementa=a-1;

Page 21: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUTvoid main(){

char s=5;s++;printf(“%d”,s);printf(“%d”,s++);printf(“%d”,s);printf(“%d”,++s);printf(“%d”,s);

}

66788

Page 22: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUTvoid main(){

int s=5;s++;printf(“%d”,s);printf(“%d”,s--);printf(“%d”,s);printf(“%d”,--s);printf(“%d”,s);

}

66544

Page 23: Time to Put on your  thinking Hats

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

Page 24: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUTvoid main(){

char s=5;printf(“%d%d%d%d”,++s,++s,s++,++s);printf(“\n%d”,s);

}9 8 6 69

Page 25: Time to Put on your  thinking Hats

WHAT WOULD BE THE OUTPUT

Bitwise Operators3^2&~1

1