Hm it's kind of hard to read your code but if
you are a C begginer the first think you should know is what
exacly you need first. You said that in C++ it works all you need
to change in here if you are begginer just the cin>> is almost the
same as "scanf" if you know what it does and also if you wont to
use printf instead of cout ok i hope it helps