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;

## No comments:

## Post a Comment