top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

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

0 votes
71 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;
}
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...