By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,778 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,778 IT Pros & Developers. It's quick & easy.

WHY output is like that

P: 1
# include <stdio.h>
# include <conio.h>
main()
{
unsigned i=1;
signed j=-1;
clrscr();
if(i<j)
printf("small");
else if(i>j)
printf("greater\n");
else
printf("Equal");

getch();
}




output is small
pls explain me why?
Mar 21 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 1,510
you are comparing signed and unsigned operands and, using the usual arithmetic conversions, the signed value is converted to a large unsigned value, see 710 in
http://c0x.coding-guidelines.com/6.3.1.8.html
Mar 21 '07 #2

dmjpro
100+
P: 2,476
a new thing i come to know ......

but it would be better if u r more clear ...... i mean how the default conversion happens in C or C++ ... as in java this is very obvious , so it is called strongly typed langauge


thanx ...
Mar 21 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.