0

Why 5th position printed as zero I expected it as 16

#include<stdio.h> int main() { char c=48; int i, mask=01; for(i=1; i<=5; i++) { printf("%c", c|mask); mask = mask<<1; } return 0; }

31st Jul 2019, 1:24 AM
Shaik Abeedh
Shaik Abeedh - avatar
1 Answer
0
Because your type specifier is %c, which means a character, the value of c will stay 48 in the fifth iteration, 48 is ASCII is 0, plus there's no character "16" in ASCII. If you want to do that, I suggest you to use an integer instead
31st Jul 2019, 2:33 AM
Agent_I
Agent_I - avatar