Also, one should make use of the return value from scanf so one can see if it worked. If you don't, it is dangerous as some of the values may contain garbage.
"And I would use iostream over C input and output"
I don't get what that is mean?
They mean use std::cin , std::getline, std::cout and others to do the same thing as scanf and printf