0% found this document useful (0 votes)
1 views

Lab 1

The lab manual covers the fundamentals of programming, focusing on Integrated Development Environments (IDEs), problem-solving, and algorithms. It introduces C and C++, detailing the history of C++, installation steps for Visual Studio, and basic programming concepts such as header files and the main function. Additionally, it explains algorithms, pseudo-code, and includes lab tasks for students to practice writing algorithms.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Lab 1

The lab manual covers the fundamentals of programming, focusing on Integrated Development Environments (IDEs), problem-solving, and algorithms. It introduces C and C++, detailing the history of C++, installation steps for Visual Studio, and basic programming concepts such as header files and the main function. Additionally, it explains algorithms, pseudo-code, and includes lab tasks for students to practice writing algorithms.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Lab Manual Programming Fundamental

Lab 01: Integrated Development Environment (IDE),


Object Oriented Programming
Problem solving and Algorithms
Objective(s):
Understanding of Integrated Development Environment (IDE) & Learn about problem solving
and algorithms.
CLOs: CL01, CLO4
Tools(s):
• PC with Windows 7 Professional or above
• Visual Studio 2022

HISTORY OF C and C++


C++ was developed by Danish computer scientist Bjarne Stroustrup at Bell Labs since 1979 as an
extension of the C language; he wanted an efficient and flexible language similar to C that also provided
high-level features for program organization.

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. Microsoft Visual Studio


Microsoft Visual Studio is IDE for Windows application development, look no further than to Microsoft's
own developer toolset. Visual Studio products cover languages like C++, C# and VB.NET. In addition,
you are also able to develop for the Windows x86, Windows RT, and Windows Phone. The latest version
of Visual Studio is also designed to be optimized for touch, just in case you happen to be writing code on
a Microsoft Surface.
2. Eclipse
Eclipse contains a base workspace and an extensible plug-in system for customizing the environment.
Written mostly in Java, Eclipse can be used to develop applications. By means of various plugins, Eclipse
may also be used to develop applications in other programming languages: Ada, ABAP, C, C++,
COBOL, FORTRAN, Haskell, JavaScript, Lasso, Lua, Natural, Perl, PHP, Prolog, Python, R, Ruby
(including Ruby on Rails framework), Scala, Clojure, Groovy, Scheme, and Erlang.
3. Code Blocks
Code::Blocks is a free, open-source cross-platform IDE that supports multiple compilers including GCC,
Clang and Visual C++. It is developed in C++ using wxWidgets as the GUI toolkit. Using plugin
architecture, its capabilities and features are defined by the provided plugins. Currently, Code::Blocks is
oriented towards C, C++, and FORTRAN. It has a custom build system and optional Make support.
Code::Blocks is being developed for Windows and Linux.

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.

Installation of Visual Studio


STEP 1
Download latest Setup of Visual Studio from official site
https://visualstudio.microsoft.com/downloads/
STEP 2
Select the free download from Community Edition.

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

Language Packs window displays the languages IDE supports.

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

Create New Project


STEP 1
Select “Create a new Project” from Visual Studio Starter Window

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.

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 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.

5. Compilation and Running a Program

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.

Problem solving and Algorithms


In computing, we focus on the type of problems categorically known as algorithmic problems, where their
solutions are expressible in the form of algorithms.

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).

Input Algorithm Output

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

Pseudo-code is a method of describing computer algorithms using a combination of natural language


and programming language. It is essentially an intermittent step towards the development of the actual
code. It allows the programmer to formulate their thoughts on the organization and sequence of a
computer algorithm without the need for actually following the exact coding syntax. Although pseudo-
code is frequently used there are no set of rules for its exact implementation. In general, here are some
rules that are frequently followed when writing pseudo-code:

 Symbols are used for arithmetic operations (+, -, *, /, **).


 Symbolic names are used to indicate the quantities being processed.
 Certain keywords can be used, such as PRINT, WRITE, READ, INPUT, OUTPUT etc.

Examples of Algorithms:

Write an algorithm to find area of a rectangle

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

Write an algorithm to add two numbers.

Step 1: Start
Step 2: get num1 and num2 value
Step 3: Calculate Sum=num1 + num2
Step 4: Display Sum
Step 5: Stop

Write an algorithm to Calculate the Area of a Parallelogram.


Step 1: start
Step 2: get b (length of base of parallelogram), l (length of height of parallelogram).
Step 3: Calculate Area A=b*l
Step 4: Display A

Lab Tasks:

1) Write an algorithm to Calculate average of two numbers.


2) Write an algorithm to Calculate the Perimeter of a Rectangle.

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

You might also like