genrica

How to Write a Program in DevC++

Writing your first program in Dev C++

Note: Note that the same steps, given below, are followed to write/compile/run a C/C++ program in Windows Vista or Windows 7 as well.

Step 1:

Starting the Dev C++ Compiler

Starting the Dev C++ Compiler
Figure 1. Starting the Dev C++ Compiler

Step 2:

Opening a new file, source file

Opening a source file
Figure 2. Opening a source file

Step 3:

Writing the code of your program

Writing the code
Figure 3. Writing the code

Step 4:

To Save the file, after naming the file, click on Save button

Saving file
Figure 4. Saving file
Naming and Saving file
Figure 5. (1) Naming the source file. (2) Saving the file

Step 5:

To execute the program, click on compile & Run the program

Execute the program
Figure 6. Execute the program

Output

After the above program is executed, the output can be seen as given below.

Output of the program
Figure 7. Output of the program

Important Note:

Note that when a program is successfully compiled in Dev C++ version 4.9.9.0 and version 4.9.9.2, a header file warning is displayed at the bottom of the as can be seen in the screenshot.

Warning displayed
Figure 8. Warning displayed

The highlighted red box shows the warning generated after the successful compilation. Do not get confused with it as it is not any kind of error and your program will run successfully even if this warning is in the program.

How to remove the header file warning?

To remove the above warning, declare the header file as #include<iostream> and also write the statement using namespace std; at the beginning of your program code. Below is the screenshot to do this.

using namespace
Figure 9. using namespace