Algorithm:

An Algorithm is a step by step instruction required to solve any problem.  For example we are going to make tea then we follow some step to make tea. These steps are called Algorithm.

Examples:

Some example Questions are given below you can easily understand the concept of Algorithm from these questions.

Question No.1

Write a program that calculate and display the area of a rectangle?

Solution:

Int h,w,A;

Cout<<”Enter height of rectangle=”;

Cin >>h;

Cout<<”Enter Width of rectangle=”;

Cin>>w;

A=h*w;

Cout<<”Area of rectangle=”<<A;

Question No.2

Write a Program to calculate and display the area of triangle?

Solution:

Float base,hight,area;

Cout<<”Base of triangle=”;

Cin>>base;

Cout<<”Height of triangle=”;

Area=(base*height)/2.0;

Cout<<”area of triangle=”<<area;

Question No.3:

Write a program that take basic salary and bonus as input then calculate the tax. On basic salary @5% then calculate total salary by adding bonus to basic salary and deduct tax?

Solution:

Float  BS,Bonus,TS;

Cout<<”input basic salary=”;

Cin>>BS;

Cout<<”Inter Bonus=”;

Cin>>Bonus;

Tax=BS*5/100.0;

TS=BS+Bonus-Tax;

Cout<<”total Salary =”<<TS;