retagged by
733 views

1 Answer

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) 

selected by

Related questions

0 votes
0 votes
1 answer
1
eyeamgj asked Nov 22, 2017
316 views
main(){int a;scanf("%i"&a);printf("%i %d",a,a);scanf("%d",&a);printf("%i %d",a,a);}suppose user entered 0x56 as input .what is printed by above program?
2 votes
2 votes
1 answer
3
Prayag asked Jul 16, 2018
440 views
#include <stdio.h void f(char ); int main() { char *argv[] = { "ab", "cd", "ef", "gh", "ij", "kl" }; f(argv); return 0; } void f(char p) { char *t; t...
2 votes
2 votes
1 answer
4
Sugumaran asked Feb 7, 2018
482 views
#include<stdio.h int main() { int x=191; char *p; p=(char*)&x; printf("%d",*p); }explain it