1 votes 1 votes main() { int a; scanf("%i"&a); printf("%i %d",a,a); scanf("%d",&a); printf("%i %d",a,a); } suppose user entered 0101 as input .what is printed by above program? Programming in C programming-in-c non-gate + – eyeamgj asked Nov 22, 2017 • retagged Nov 22, 2017 by Arjun eyeamgj 769 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 5 votes 5 votes The difference between %i and %d is that when used with scanf(), then %d always takes a decimal integer, whereas %i recognizes the 0 and 0x prefixes as octal and hexadecimal. So when input is given as 0101 0101 then 1st printf() output: 65 65 (octal value of 0101) 2nd printf() output: 101 101 (it simply ignores prefix 0) kirti_k answered Nov 22, 2017 • selected Nov 24, 2017 by eyeamgj kirti_k comment Share Follow See all 7 Comments See all 7 7 Comments reply Show 4 previous comments Arjun commented Nov 22, 2017 reply Follow Share See what you did is CTRL+C, CTRL+V from stackoverflow and you did not even give a reference link to it as mandated by stackoverflow in their terms and condition. This is not a good way to share knowledge. 1 votes 1 votes Hira Thakur commented Nov 22, 2017 reply Follow Share how the input 0101 is providing 2 times, so that it prints 65,65 ?? 0 votes 0 votes kirti_k commented Nov 22, 2017 reply Follow Share okay I'm sorry sir it won't happen again :) 0 votes 0 votes Please log in or register to add a comment.