what would be the output of the following prog? Justify
your answer?
main()
{
unsigned char ch;
unsigned char i;
ch = -255;
printf("%d",ch);
i = -1;
printf("%d",i);

}



what would be the output of the following prog? Justify your answer? main() { unsigned char ch;..

Answer / bittu

1255

this is because -255 (00000001) when considered unsigned
looks like 1(00000001) in binary and -1(11111111) when
considered unsigned looks like 255(11111111) in binary
(11111111).

refer to this
http://www.allaboutcircuits.com/vol_4/chpt_2/3.html

Is This Answer Correct ?    5 Yes 0 No

Post New Answer

More C Interview Questions

how can i print "hello"

3 Answers  


How to find the digits truncation when assigning the interger variable to the character variables. like int i=500; char x = i : here we have truncation. how to find this. another ex: i =100; char x=i. here we do not have truncation.

1 Answers   HCL,


Explain pointers in c programming?

0 Answers  


What are variables and it what way is it different from constants?

0 Answers  


How do you sort filenames in a directory?

0 Answers  






Difference Between embedded software and soft ware?

1 Answers   Bosch,


marge linklist

0 Answers   HCL,


Is array a primitive data type in c?

0 Answers  


struct node {struct node*temp,*new} prinf("%d",sizeof(struct node));

2 Answers  


What does int main () mean?

0 Answers  


int x=5; printf("%d%d%d",x,x<<2,x>>2);

2 Answers   TANCET,


What does *p++ do? What does it point to?

0 Answers  


Categories