+ 2

Is this the right way??

Why is this code not asking for an input? https://code.sololearn.com/cZD1e5zIG91W/#cpp #include <iostream> int main() { int a= 10; scanf("%d", &a); printf("%d", a); std::cout<<a; return 0; } but just prints 1010 Compiler: https://code.sololearn.com/#cpp

2nd Sep 2020, 5:58 AM
Tom
Tom - avatar
1 ответ
+ 5
Its not asking for input becoz the function which u used printf and scanf these are defined in stdio.h header file here u not include stdio.h but printf is printing 10 but its depend on Compilers or ide i tried in other ide its asking for input . May be some Compilers will give you warnings. Cpp is a superset lang. Of c so mostly cpp Compiler supporting c lang. features also so here u not getting errors or warning but your scanf part not working here.
2nd Sep 2020, 6:26 AM
A S Raghuvanshi
A S Raghuvanshi - avatar