+ 1
What is the output of the code?? when input is 4 c.................
#include <stdio.h> int main() { int a; char c; scanf("%d%c",&a,&c); printf("%d%c",a,c); return 0; } 4 c is wrong answer :->
6 Answers
+ 4
The next character value is assigned to c, in Code Playground we can test this by changing the printf format with "%d%d" then in Code Playground input dialog if you type '4 c' the output would be '432' and if we type '4', {Enter} and type 'c' the output would be 410. Notice what came after 4, in the first input '4 c' there's a space between 4 and 'c' and space ASCII code is 32, hence '432'. The same with '410', ASCII code for line break is 10.
Hth, cmiiw
+ 3
right ans is 4
+ 3
yes if u consider after 4 there is a space then printf only print 4
+ 2
4c is ans
+ 2
No
+ 2
but here in code %d%c.. so 4c isn't right ans?