This is because a & r are of different types, when comparing, a is
casted to be unsigned int (32 bits) with bit 1 in the MSB, and this is a
very large number. To solve this problem, u have to make the comparison
between two variables of the same type.
since u r using negative values, make it:
int a = -5;
int r = 2000; /*not unsigned int*/
if u want to make r as unsigned int, u will have to make casting in the
compare statement.
if (a > (int)r) /*this works correctly*/
Regards,...
TheOldWiseKing
Uday Oberio wrote:
> hello everyone
> i m very new in this so please help.
> thanx in advace,,,,
>
> my problem is this : -
>
> #include<stdio.h>
> #include<conio.h>
> void main()
> {
> int a=-5;
> unsigned int r=2000;
> if(a>r)
> printf( " a is greater than r ");
> else
> printf(" r is greater than a");
> }
>
> In this programe the output is = a is greater than r why please
> explain me how it can be....
> and also tel me i m very new in this filed please tell me from where
> should i get the knowldge of 'C' programming...
> thanx a lot in advance...
> arun.,,,,,
> waiting for u r reply....
>
>
> ---------------------------------
> Download prohibited? No problem. CHAT from any browser, without download.
>
> [Non-text portions of this message have been removed]
>
>
[Non-text portions of this message have been removed]