Lab 1
Lab 1
INTRODUCTION (IDE):
An integrated development environment (IDE) or interactive development environment is a software
application that provides comprehensive facilities to computer programmers for software development.
An IDE normally consists of a source code editor, build automation tools and a debugger. In general, an
IDE is a graphical user interface (GUI) - based workbench designed to aid a developer in building
software applications with an integrated environment combined with all the required tools at hand.
Examples of IDEs:
1
Lab Manual Programming Fundamental
4. Turbo C/C++
Turbo C is an Integrated Development Environment and compiler for the C programming language from
Borland. First introduced in 1987, it was noted for its integrated development environment, small size,
fast compile speed, comprehensive manuals and low price.
STEP 3
Double Click on downloaded installer. Allow the installer to make changes to your computer.
STEP 4
Click on Continue.
STEP 5
Workloads window shows the options of different workloads supported by Visual Studio IDE.
Select Desktop development with C++. You can select other or multiple workloads as well to work with.
2
Lab Manual Programming Fundamental
Individual Components window enlists components for different tools, frameworks and development life
cycle.
3
Lab Manual Programming Fundamental
Installation Locations window displays the default locations for the installation of Visual Studio IDE.
STEP 6
Click on “Install” button.
4
Lab Manual Programming Fundamental
STEP 7
Setup will install Visual Studio
Getting Started
Choose color theme and Start Visual Studio
5
Lab Manual Programming Fundamental
STEP 2
Select Console Application and click “Next” Button.
6
Lab Manual Programming Fundamental
STEP 3
Configure your project your name and location. Create your new Project.
Step 4
Explore IDE layout.
7
Lab Manual Programming Fundamental
STEP 5
Add a source file, to the project. Right Click Add New Item
8
Lab Manual Programming Fundamental
STEP 6
Select Visual C++ from the ―Installed Templates. Select .cpp extension file from the list. Name the
source file first project.
1. Header Files
A header file is a file 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.
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 corresponds to a standard output stream. It is used to display the
9
Lab Manual Programming Fundamental
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.
Press Ctrl+ Shift + B to compile. If there is no error the program compiles successfully. Press Ctrl + F5 or
green outlined triangle to run the program.
An algorithm a well-defined computational procedure consisting of a set of instructions that takes some
value or set of values, as input, and produces some value or set of values, as output. In other word, an
algorithm is a procedure that accepts data; manipulate them following the prescribed steps, so as to
eventually fill the required unknown with the desired value(s).
Tersely put, an algorithm, a jargon of computer specialists, is simply a procedure. People of different
professions have their own form of procedure in their line of work, and they call it different names. A cook,
for instance, follows a procedure commonly known as a recipe that converts the ingredients (input) into
some culinary dish (output), after a certain number of steps.
An algorithm is a form that embeds the complete logic of the solution. Its formal written version is called
a program, or code. Thus, algorithmic problem solving actually comes in two phases: derivation of an
algorithm that solves the problem, and conversion of the algorithm into code. The latter, usually known as
coding, is comparatively easier, since the logic is already present – it is just a matter of ensuring that the
syntax rules of the programming language are adhered to. The first phase is what that stumbles most people,
for two main reasons. Firstly, it challenges the mental faculties to search for the right solution, and secondly,
it requires the ability to articulate the solution concisely into step- by-step instructions, a skill that is
acquired only through lots of practice. Many people are able to make claims like “oh yes, I know how to
solve it”, but fall short when it comes to transferring the solution in their head onto paper.
Algorithms and their alter ego, programs, are the software. The machine that runs the programs is the
hardware.
10
Lab Manual Programming Fundamental
Pseudo-code
Examples of Algorithms:
Step 1: Start
Step 2: get l(length) and w(width) values
Step 3: Calculate area A = l * w
Step 4: Display A
Step 5: Stop
Step 1: Start
Step 2: get num1 and num2 value
Step 3: Calculate Sum=num1 + num2
Step 4: Display Sum
Step 5: Stop
Lab Tasks:
11
Lab Manual Programming Fundamental
Hint: perimeter=2*(length*width)
3) Write an algorithm to Convert Kilometers to Miles. Hint :mile=k*0.621371
4) Write an algorithm to find velocity of a moving object.
5) Write an algorithm to Calculate Simple Interest.
6) Write an algorithm to find volume of cylinder.
12