You must have a C or C++ compiler like GCC, Visual C++, etc. already installed in your system. If you don’t have any, you can easily get them by searching on Google.

How to Run C and C++ Program in CMD

1.Before running programs we must set the path of compiler. So, first right click on Computer icon and go to Properties option.

2. Click on Advance system settings and then Environment Variables.

3. A new window will open, there click on New button. In Variable name filed enter path and in Variable value filed enter the path of the bin folder of compiler.

4. You can find the path of bin folder by going to the directory where you have installed the compiler.

5. After that click all OK buttons to save the information.

6. Press Win+R keys to open Run. Type cmd and press enter to open command prompt.

7. Now change the directory to where you have saved your C or C++ program file. Lets say you have saved the program on Desktop then type cd desktop and press enter.

8. Now for compiling the program type gcc filename. Here filename is the name of the program file. I have used gcc command because I have installed GCC compiler in my system. The command will change if you are using any other compiler, like for Turbo C++ it will be tcc, for Borland C++ it will be bcc and so on.

9. For running the program just type the name of the source file without .c or .cpp extension and press enter.

10. If you have followed steps properly then you can see the output.

Comment below if you have any doubts regarding above how to run C and C++ program in CMD article.