iostream is C++ library. Maybe you compiled the code for C only (top right corner)?
The following code works fine in C++ (but obviously does not compile in C), check it:
std::cout << "Hello World" << std::endl;
printf() function is a function of 'C' language. It is used to print something in output screen (Same as cout function in 'C++' language). This requires stdio.h header file to be executed (Some times it also runs without any header file, depending upon the compiler you use!).
Syntax for displaying hello world :-
Note:- Make sure you give a semicolon(;) after printf statement.
And if you want to display value of a variable.
Syntax to print value of a :-
Note:- Here %d is a format specifier. If you don't know, search for it...