How to run a C program in notepad++?

To run C program C language Compiler and editor is used. But C language programs can also be run by using cmd (command prompt). A sequence of steps need to be carried out in order to execute the C language program at command prompt. These steps are useful when a notepad is used to write a C language program. 

Follow are the steps to run program at command prompt:

  • Open Notepad, this can be done two ways:
  • In the search box of startup type run and enter.
  • When the run window appears click on it, to open the run window.
  • In the run window type Notepad or Notepad++ to open notepad.
  • Notepad can also be opened by right clicking on the desktop and choosing New Text document form there.

When Notepad opens, type C language program. Type the following C language program.

#include<stdio.h>
         Void main ( )
         {
               printf(“These are steps to run program using Notepad++”);
               return(0);        
         }
  • Save the written program in the directory in which you have installed C language Compiler.
  • To compile the program open command prompt.
  • At the command prompt use cd  command to change directory and move to the location where the program is saved.
  • When you are at the location where the program is saved you are ready to execute the program.
  • To compile the saved program and get executable code type the following command at the command prompt.

gcc <program name>.c   -o  <hello>.exe

 Example:

gcc     learn.c     -o learn.c

  • By running gcc command at command prompt executable code of the saved program, to obtain the output this executable code needs to be run.
  • To run the executable you need to run the following command at the command prompt.

./ <program_name>.exe

Example:

./ learn.exe

Note: You need to check whether the C compiler is installed or not. To check this, type the following command at the command prompt.

At the command prompt type this command prompt:

  • gcc -v
  • Output should give the version of the gcc installed at the last.