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

}

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is unsigned int in c?

565


writ a program to compare using strcmp VIVA and viva with its output.

1530


How do I convert a string to all upper or lower case?

633


What is the difference between volatile and const volatile?

571


Does free set pointer to null?

569






which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above

1421


How would you rename a function in C?

625


What is the purpose of realloc()?

677


What are the 4 data types?

604


How can I delete a file?

633


What is an array? What the different types of arrays in c?

662


Do pointers need to be initialized?

571


what is a function method?give example?

1918


show how link list can be used to repersent the following polynomial i) 5x+2

1683


List the difference between a While & Do While loops?

641