Lab 1 Updated
Lab 1 Updated
Objectives:
Introduction to Code::Blocks
Writing a new C++ Program
Programming Errors
Introduction to Code::Blocks
Code::Blocks is a free C++ IDE developed by The Code::Blocks Team. It is a free, open-source and
cross-platform IDE, which supports various free compilers.
1. Menu bar:
Few important links in menu bar are:
File: It contains options to create a new project, open an already existing project, save file,
save project, save workspace and save everything. Other options in File are to print, export
and quit the Code::Block
Edit: All the editing options required for editor are provided in Edit.
View: This menu link contains link for various perspectives and toolbars along with manager,
logs, script console, status bar, full screen.
Project: Options related to the project is provided in this link which includes adding files,
removing files and auto versioning of project.
Build: Options for building the project, compiling a single file, running, building and running
the project, rebuilding and cleaning the project/workspace is provided in build.
Debug: Various Debugging options are provided in this link.
Plugins: Various plugins can be executed using this link. The link to manage the plugins is
also provided here.
Settings: This contains link for various settings, setting related to Environment, Editor,
Compiler and debugger, Global Variables and Script to be executed can also be edited here.
Help: It contains information about Code::Block version, tips which can be toggled to be
displayed at start-up and information about various plugins.
5. Manager:
Manager window provides the list of all the open projects and files for easy access to any required
file of any project.
A short-cut on Starting page of IDE for creating a new project and opening an already created
project is present. It also contains link for Code::Block forum where many useful resources can be
found along with other useful discussions.
6. Logs:
It is labelled as Logs & others. This window acts as log for various actions performed in IDE.
All logs related to various activities can be checked at appropriate windows.
Click File New Project. A new window opens. Click Console application Click
Go.
When Go button is clicked, a new window opens. Select checkbox Skip this page next time so
that the page is not displayed again. Click Next.
Next window enables user to select the language to be used for project. Click C++ Next
Next windows enables user to provide title for the project and the folder where user wishes to
create the project in. After filling in the details click on Next.
Use a meaningful name, Camel case (if necessary).
Next window is used to select the compiler. By default GNU GCC Compiler is selected.
Click Finish.
Line 5: main ( )
This line initiates the declaration of a function. Main is a special function in all C++ programs; it is
called when the program is run. The execution of all C++ programs begins with the main function.
Lines 6 and 8: { }
The open brace { at line 6 indicates the beginning of main's function definition, and the closing brace
} at line 8, indicates its end. Everything between these braces is the function's body that defines what
happens when main is called. All functions use braces to indicate the beginning and end of their
definitions.
Programming Errors:
Syntax Errors
Logical Errors
Run time Errors
Lab Report:
1: Write down the following code in compiler and see the result.
2: Write a program that prints a box, an oval, an arrow and a diamond as follows: [Hint: setw( ) &
<iomanip >]
3: What does the following code print?