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

Algorithm

The document provides algorithms and flowcharts for 9 problems involving mathematical and logical operations in C++. These include finding the area and perimeter of shapes, temperature conversions, finding factors and compound interest, swapping variables, and calculating a factorial.

Uploaded by

Gemechis Gurmesa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Algorithm

The document provides algorithms and flowcharts for 9 problems involving mathematical and logical operations in C++. These include finding the area and perimeter of shapes, temperature conversions, finding factors and compound interest, swapping variables, and calculating a factorial.

Uploaded by

Gemechis Gurmesa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

C++ ASSIGNIMENT

WOLAITA SODO UNIVERSITY

DEPARTMENT : Mathematics
COURSE: C++
NAME: George Seyum
ID number: ugr/69438/14

Individual assigniment
C++ ASSIGNIMENT

Instructor name: Indashaw Wolde


Submission date 20/ 02/2016 EC

Individual assigniment
C++ ASSIGNIMENT

1. Algorithm & Flowchart to find Area and Perimeter of Square

L : Side Length of Square


Start
AREA : Area of Squarearea

PERIMETER : Perimeter of Square


Input value of L

Algorithm L

Step-1 Start

Step-2 Input Side Length of Square say L Area= L*L

Step-3 Area = L x L

Step-4 PERIMETER = 4 x L Perimeter = 4*L

Step-5 Display AREA, PERIMETER

Step-6 Stop Print AREA,


PERIMETER

Stop

Individual assigniment
C++ ASSIGNIMENT

2. Algorithm & Flowchart to find Area and Perimeter of Rectangle

L : Length of Rectangle Start

B : Breadth of Rectangle

AREA : Area of Rectangle Input value of L,


B
PERIMETER : Perimeter of Rectangle

Algorithm
Step-1 Start Area= L*B
Step-2 Input Side Length & Breadth say L, B

Step-3 Area = L x B
Perimeter =
Step-4 PERIMETER = 2 x ( L + B) 2*(L+B)

Step-5 Display AREA, PERIMETER


Print AREA,
Step-6 Stop PERIMETER

Start

Individual assigniment
C++ ASSIGNIMENT

3. Algorithm & Flowchart to convert temperature from Fahrenheit to Celsius

C : temperature in Celsius

F : temperature Fahrenheit
Start
Algorithm
Step-1 Start

Step-2 Input temperature in Fahrenheit say F


Input value of F
Step-3 C = 5.0/9.0 (F - 32 )
L
Step-4 Display Temperature in Celsius C

Step-5 Stop
C=5/9(F-32)

Print C

Stop

Individual assigniment
C++ ASSIGNIMENT

4. Algorithm & Flowchart to convert temperature from Celsius to Fahrenheit

C : temperature in Celsius

F : temperature Fahrenheit Start

Algorithm
Step-1 Start

Step-2 Input temperature in Celsius say C Input value of C

Step-3 F = (9.0/5.0 x C) + 32 L

Step-4 Display Temperature in Fahrenheit F

Step-5 Stop
F =9/5*C+32

Print F

Individual assigniment
C++ ASSIGNIMENT

Stop

5. Algorithm & Flowchart to find Area & Perimeter of Triangle

(when three sides are given)

A : First Side of Triangle


Start
B : Second Side of Triangle

C : Third Side of Triangle

AREA : Area of Triangle


Input value of
A,B, C
PERIMETER : Perimeter of Triangle

Algorithm
Step-1 Start
S=(A+B+C)/2
Step-2 Input Sides of Triangle A,B,C

Individual assigniment
C++ ASSIGNIMENT

Step-3 S= (A + B + C)/ 2.0

Step-4 AREA = SQRT(S x (S-A) x (S-B) x(S-C))


AREA =SQRT(S*(S – A ) X*(S-B)*(S
Step-5 PERIMETER = S1 + S2 + S3 – C))

Step-6 Display AREA, PERIMETER PERIMETER = A+B+C

Step-7 Stop

Print area,
perimeter

stop

6. Algorithm & Flowchart to find all the divisor of a number

Algorithm
Step-1 Start Start

Step-2 Read number N

Step-3 D=1

Step-4 WHILE (D< N) Read N

DO L

Individual assigniment
C++ ASSIGNIMENT

IF ( N % D ==0) THEN
D=1
PRINT D
L
ENDIF

D=D+1

DONE No
if
STOP
Step-5 Sop
CTRL< N

yes

IF
yes PRINT D
(N%D==0)

No

D = D+1

7. Algorithm & Flowchart to find Compound Interest

P : Principle Amount

N : Time in Years
start
R : % Annual Rate of Interest

Individual assigniment
C++ ASSIGNIMENT

CI : Compound Interest

Algorithm
Input value of
Step-1 Start
P.N.R

Step-2 Input value of P, N, R C

Step-3 CI = P(1+R/100)N - P

Step-4 Display CI
CI = P*(1+R/100)^N-F
Step-6 Stop

Print CI

STOP

Individual assigniment
C++ ASSIGNIMENT

8. Algorithm & Flowchart to Swap Two Numbers using Temporary Variable

Algorithm
Step-1 Start

Step-2 Input Two Numbers Say NUM1,NUM2 start


Step-3 Display Before Swap Values NUM1, NUM2

Step-4 TEMP = NUM1

Step-5 NUM1 = NUM2 Input value of

Step-6 NUM2 = NUM1 NUM 1, NUM 2

Step-7 Display After Swap Values NUM1,NUM

Step-8 Stop
Write value of

NUM1, NUM2 before


swap

TEMP = NUM 1

NUM 1 = NUM 2

NUM 2 = TEMP

Write value of

NUM 1, NUM 2 after


swap

STOP

Individual assigniment
C++ ASSIGNIMENT

9. Algorithm & Flowchart to find Factorial of number n ( n!=1x2x3x…n)

Algorithm
Step-1 Start
start
Step-2 Read number N

Step-3 FACT=1 CTRL=1

Step-4 WHILE (CTRL <= N)


Read N
DO

FACT=FACT*I

CTRL=CTRL+1

DONE FACT =1

CTRL = 1
Step-5 Display FACT

Step-6 Stop

No
If Print

CTRL<=N FACT

yes

STOP
FACT = FACT *CTRL

Individual assigniment

CTRL = CTRL + 1
C++ ASSIGNIMENT

10. Algorithm & Flowchart to Swap Two Numbers without using temporary

variable
start
Algorithm
Step-1 Start

Step-2 Input Two Numbers Say A,B

Step-3 Display Before Swap Values A, B Input value of

Step-4 A = A + B A,B

Step-5 B = A - B

Step-6 A = A - B

Step-7 Display After Swap Values A, B

Step-8 Stop
Write value of

A, B before swap

A = A+B

B= A-B

A=A-B

Individual assigniment
C++ ASSIGNIMENT

Write value of

A B after swap

STOP

Individual assigniment

You might also like