Q1 In C, characters have ASCII codes in range 0-255. How can we print characters having ASCII code from 128-255.
printf("%c",(unsigned)129); //it will still print the char having ASCII -127
ASCII is a 7-bit code, ranging from 0 - 127. Extended ASCII may be different here or there. The character you may see may be the extended ASCII character whose value is 129.
Q2 ASCII char range is 0-255,then where do the characters having -127 to 0 ASCII code come from.
See above.
Q3 Where r the local & global static variables stored.
Why do you ask? If it's homework, take a stab at it first.
Q4 I read that const variables r stored in rom. How cum bcoz as far as i know rom can be programmed only by hardware means.
The keyword const really means read-only. Whether or not a const variable is placed in ROM depends on the platform.
Q5 int a=9999;
float *p=(float *)&a;
printf("%f",*p); //output is 0.000000 why?
Behavior is undefined because you are lying to printf.
Q6 printf("%d%d",10ul,10); //output is 100 why?
See above. (My output is 1010).
Q7 float f=10.67;
int *p=(int *)&f;
printf("%d",*p); //output is -18350 why?
See above. (My output is 1093318738).
Reputation Points: 2780
Solved Threads: 312
long time no c
Offline 4,790 posts
since Apr 2004