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

Lab Manual 2

Lab Manual 2

Uploaded by

osmani.acs22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Lab Manual 2

Lab Manual 2

Uploaded by

osmani.acs22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Department of

Computer Science and Engineering

Title: Problem Analysis and Algorithm Design

Computational Thinking and Problem Solving


CSE 100

Green University of Bangladesh


Objectives:
1. Familiarization with algorithm
2. To analyze a problem with computational thinking
3. To design the algorithm for that problem

Problem Analysis:
Algorithm:

In computer programming terms, an algorithm is a set of well-defined instructions to solve a


particular problem. It takes a set of input(s) and produces the desired output.

For example-

An algorithm to add two numbers:

1. Take two number inputs

2. Add numbers using the “+” operator

3. Display the result

Properties of Algorithm:

● It should terminate after a finite time

● It should produce at least one output

● It should take zero or more input

● It should be deterministic means giving the same output for the same input case

● Every step in the algorithm must be effective.

1. Problem Description: Add two numbers entered by the user

Algorithm:

Step 1: Start

Step 2: Declare variables num1, num2, and sum.

Step 3: Read values num1 and num2.

Step 4: Add num1 and num2 and assign the result to sum.

sum← num1 + num2


Step 5: Display sum

Step 6: Stop.

2. Problem Description: Find the factorial of a number

Algorithm:

Step 1: Start

Step 2: Declare the variables num, factorial and i

Step 3: Initialize variables

factorial ← 1

i←1

Step 4: Read the value of num

Step 5: Repeat the steps until i == num

5.1: factorial ← factorial*i

5.2: i ← i+1

Step 6: Display factorial

Step 7: Stop

3. Problem Description: Find the Fibonacci Series till the term is less than 50

Algorithm:

Step 1: Start

Step 2: Declare the variables first_term, second_term, and temp

Step 3: Initialize variables

first_term ← 0

second_term ← 1

Step 4: Display first_term and second_term

Step 5: Repeat the steps until second_term < 50

5.1: temp ← second_term


5.2: second_term ← second_term + first_term

5.3: first_term ← temp

5.4: Display second_term

Step 6: Stop

Discussion and Conclusion


Based on the focused objectives, be familiar with algorithm and able to design the algorithm of a
given problem. The additional lab exercise made me more confident in the fulfillment of the
objectives.

Lab Task (Please implement yourself and show the


output to the instructor)
1. Find the largest number among three numbers

2. Check whether a given number is even or odd

3. Check whether a year is a leap year or not

4. Print numbers from 1 to n.

5. Swap two numbers using a third variable

Lab exercise (submit as a report)


1. Check whether a number is prime or not

2. Calculate the summation of even numbers from 1 to n

3. Check whether a triangle is equilateral, isosceles, or scalene.

4. Print multiplication table of a given number n

5. Find the Fibonacci series of first n terms.

Policy
Copying from the internet, classmates, seniors, or from any other source is strongly prohibited.
100% marks will be deducted if any such copying is detected.

You might also like