Doubt in suffix for a variable

Status
Not open for further replies.

Murugesh_89

Full Member level 5
Joined
Nov 23, 2012
Messages
266
Helped
7
Reputation
12
Reaction score
6
Trophy points
1,298
Location
India
Activity points
3,267
Hi,
Please let me know the reason..

My program is...

void main()
{
int a,b;

a = -1;
b = -1u;

if(a == b) do_task1;
else do_task2;
}

The condition passes and do the task1. Why is it so even though i made b as unsigned??

Need reason for this...
 

You have declared a and b as int variables?
Code:
 int a,b;
Code:
 Change it to unsigned int a , b;
and see if you get the right value.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…