Lab Manual 01 - Working of IDE (Code Blocks)
Lab Manual 01 - Working of IDE (Code Blocks)
Lab- 01 Manual
Lab Instructor: Saima Waseem
Department of Artificial Intelligence
Email: [email protected]
LAB 01: Integrated Development Environment (IDE) Installation (Code Blocks)
and Basics of Programming.
1.1 Objective:
1. Learn basic components of a C++ program.
2. Learn compilation process.
3. Learn how to use Code Block Compiler.
4. Learn how to write, edit & run C++ Program.
1.2 Scope:
The student should know the following at the end of this lab:
1. Problem solving
2. How to install run and compile Code Block.
3. Basis structure of program
4. Writing Complete Programs
C++ program:
Functions
A function is a block of statements that make a specific kind of processing. Every C++
program has a main() function. The execution starts from main().
Variables / identifiers
These are used to store data in a program. You must declare a variable before you use it.
{ int main()
} cout<<“hello World”;
return 0;
STEP 1:
Download Setup of Code Blocks 17.12 or any latest Version.
STEP 2
Click on the Code Blocks file that you downloaded in order to install Code Blocks.
STEP 3
Click ―Next to start installation
STEP 4
https://www.youtube.com/watch?v=o1ruNcmG7L0
STEP 5
Start Code Blocks
1) Header Files
A header file is a file with extension .h which contains C++ function declarations and macro
definitions and to be shared between several source files. You request the use of a header file in your
program by including it, with the C preprocessing directive #include like you have seen inclusion of
iostream header file, which comes along with your compiler.
2) Using namespace std;
The namespace creates a declarative region in which various program elements are defined. The using
statement informs the compiler that you want to use the std namespace. If the following line is not
included the cout would not have been executed, as cout is included in the namespace std.
3) Main Function
void main() is the first statement executed whenever the C++ program is run. It is the starting point of
the program. If main function is not included in the program, the compiler will show an error. Void is a
data type of function main, it shows the program is not returning any value.
4) cout<<”Hello World”;
This line is a statement. Statements in C++ always end with semi-colon. Statements are always executed in the
order they appear. The cout correspond to a standard output stream. It is used to display the output on the screen.
The symbol “<<” refers to an insertion operator. Its function is to direct the string constants to cout which
displays it onto the screen.
1.4 Exercises for lab
Exercise 1.1: Type and save the program with the name LAB0Q1.CPP
/* Volume of a sphere */
#include <iostream >
#include<cmath>
#define PI 3.14159
int main()
{
double radius, volume;
cout<<"enter the radius > "; cin>>radius;
volume = 4.0 / 3.0 * PI * pow(radius,3);
cout<<"the radius of the sphere is :"<< radius; cout<<"the volume of the
sphere is :"<< volume;
return 0;
}