top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What are the condition when we use signed char in C in place of unsigned char?

0 votes
522 views
What are the condition when we use signed char in C in place of unsigned char?
posted Sep 5, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Mainly in case of loop.
For example:
unsigned char i = 0;

/* Infinite Loop due to unsigned nature of i */
for (i = 10 ; i < 0; i --)
{

}

Better to use signed char i = 0 to make correct execution of loop.

answer Sep 5, 2014 by Harshita
Similar Questions
+2 votes

A char can not be a +ve or -ve. last bit is signed bit in accumulator.but not useful for CHAR Whats the purpose? of doing it.

+1 vote
#include <stdio.h>
int main()
{
  char val=250;
  int ans;
  ans= val+ !val + ~val + ++val;
  printf("%d",ans);
  return 0;
}
...