Aug 14, 2014 #1 V v.s.n.kumar Member level 1 Joined Dec 2, 2013 Messages 38 Helped 0 Reputation 0 Reaction score 0 Trophy points 6 Activity points 303 Hi, can anybody tell what is the result of below lines in c. main() { int i=0x90; printf("%%d",i); }
Aug 14, 2014 #2 A ahmad1954 Full Member level 4 Joined Jun 30, 2012 Messages 192 Helped 26 Reputation 52 Reaction score 26 Trophy points 1,308 Activity points 2,102 if you use 2 % in printf in output you have %d. so your output is %d. but if use printf("%d",i) output is 144 decimal of 90 hex.
if you use 2 % in printf in output you have %d. so your output is %d. but if use printf("%d",i) output is 144 decimal of 90 hex.
Aug 14, 2014 #3 V v.s.n.kumar Member level 1 Joined Dec 2, 2013 Messages 38 Helped 0 Reputation 0 Reaction score 0 Trophy points 6 Activity points 303 I know that the result is %d. but what is the reason for giving as %d
Aug 14, 2014 #4 A ahmad1954 Full Member level 4 Joined Jun 30, 2012 Messages 192 Helped 26 Reputation 52 Reaction score 26 Trophy points 1,308 Activity points 2,102 you should use one %. because % is for formatting and every time that compiler see %,it looks for formatting option, for example d or f. and if you want to print % character, you should use %%.
you should use one %. because % is for formatting and every time that compiler see %,it looks for formatting option, for example d or f. and if you want to print % character, you should use %%.