Dev-C++ Tutorial
Dev-C++
Integrated Development Environment

This lab activity is to demonstrate the basic steps involved in coding,
compiling, executing, and testing a program in the Dev-C++ Integrated
Development Environment (v4.9.9.2). You can obtain and install his
software on you home computer by following the instructions
here.You may have other questions that are not answered here. Be sure to
check the FAQ at
the Bloodshed web site. Follow the directions
below in the order indicated.
-
Start Dev-C++ from the start menu.
-
From the "File" menu, choose
"New Source File" (or click on the "Source
file" button, the third from the left on the button bar (just
under the menu bar). An insert cursor (vertical blinking line) will
appear in the edit window.
-
Type the following line. Use the
backspace key as necessary to correct typos:
/* lab1.c -- Your Name */
-
Save your program as follows:
- From the File menu, choose "Save as
..."
- In the "Save File" dialog box that opens,
navigate to the drive/directory where you want to save your
source file.
- In the "File name" text box, change the
file name to: lab1-xxx.c
(where xxx are
your initials)
-
Click on the Save button to save
the file.
-
When you return to Dev-C++, the name of
your file should appear in the tab above the text window. Now enter the rest of the
program, exactly as shown below. Use the cursor arrow keys or
mouse and the backspace or delete keys to correct your typos.
/* lab1-jqy.c -- 100120 -- John Q. Yossarian */
/* Calculate how many dozens of eggs */
#include <stdio.h>
int main()
{
int eggs; /* number of eggs */
int dozens; /* whole dozens */
int leftOver; /* eggs left over */
printf("How many eggs do you have? ");
scanf("%d", &eggs);
dozens = eggs / 12; /* calculate dozens */
leftOver = eggs % 12; /* calculate # left over */
printf("\nThat's %d dozens, ", dozens);
printf("%d left over.\n\n", leftOver);
system("pause");
return 0;
}
|
-
When you have finished entering the
program, save it by clicking on the diskette icon (the fourth one
from the left) on the button bar (or File >> Save).
-
Compile your program: From the
"Execute" menu, choose "Compile".
-
If you typed the above program
perfectly, the Compile Progress status window window will
display the status "Done", with 0 errors and 0 warnings. If this
is not the case, you have syntax errors (typos) in your
program that need to be fixed before it can be run. To do this:
- Scroll in the bottom window to display the first syntax
error.
- Double-click anywhere in the line that explains the error.
In the Edit window, an indicator will show you in which line
of your program the compiler thinks your syntax error
occurred.
-
Read the explanation of the error
and compare your typed line with the program listing above.
The error may in this line or a line that comes before
it. Identify and correct the error.
-
Repeat steps 6-8 until you have
corrected all your syntax errors.
-
Run your program: Close the Compile
Progress window, and from the Execute menu chose "Run" (or click
on the second icon from the left on the second button bar).
-
An console window will appear and your
program will be running. Input an integer number of eggs when
you see the prompt. Your program will accept this data, and
compute and display the result and the message "Press any
key to continue." When you do, the console window will close
and you will return to Dev-C++. If you want to execute
your program again, from the
"Execute" menu, choose "Run". This program should work fine, but usually you will find logic
errors in it that will need to be corrected by repeated
analysis, editing, compiling, and testing.
-
When you are finished, exit Dev-C++ from the File menu.
|