format specifier problem in c-language

Status
Not open for further replies.

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);
}
 

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.
 

I know that the result is %d. but what is the reason for giving as %d
 

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 %%.
 

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