I'm trying to learn LaTeX, I installed MiKTeX and TeXworks as a editor and gave the path to MiKTeX in
edit/preference/typesetting. I'm trying to run some code it gives me an error that the program
pdftext.exe was not found!
You mentioned that you set the path to MikTeX. It is, however, not enough to set the path to
C:\Program Files\MikTeX 2.9\. You need to set the path to where the pdflatex.exe is located. This is
.../MiKTeX 2.9/miktex/bin as mentioned in the comment above.
The easiest is probably to write this path to the environmental variables in windows. Then
pdflatex.exe could be found anywhere on the system and there would be no need of specifying the whole path - writing
pdflatex.exe in the editor settings would be enough.
The procedure on how to set this environmental variable in Windows depends on the version you are using. In good old XP times this was found in the control panel under System in the "Advanced" tab.
But before you do all that, open a command line start->run->cmd and type in
pdflatex.exe and check if it can be found.