i have a doubt that if one of the operand is unsigned int then other will be automatically converted into same right?
so if i have 1st no. ie. unsigned and other is int but a negative one, so the int one will be converted but how can an unsigned hod negative value?
Implicit type conversion
@Ashish2001 this is the order of implicit conversion
bool -> char -> short int -> int ->
unsigned int -> long -> unsigned ->
long long -> float -> double -> long double
As you can see, signed values are converted to unsigned, and not the other way around.
but how can a negative value been assigned to an unsigned int?
then how we will get the desired output?
adding an unsigned value to a negative one
@Ashish2001 you can do explicit conversion. But why are you taking unsigned int if you need to add it to signed value later on? You can take long long int if you need a bigger range.