Experiment No.02 PART A (PART A: TO BE REFFERED BY STUDENTS)
A.1 Aim:To study Algorithm and Flow charts. Task1: Write an algorithm and draw flow chart to 1. SUM = 12 + 22 + 32 +…. N2
2. Perform mathematical operations like addition, multiplication, division and subtraction based on user’s choice. 3. Print numbers from 10 to 01. 4. To accept N numbers and find their average 5. To find whether a given number is prime or not Task 2: The following incomplete flowchart add all even numbers between 1 to 50.
Complete it by joining X with the given option
PART B (PART B: TO BE COMPLETED BY STUDENTS) (Students must submit the soft copy as per following segments within two hours of the practical. The soft copy must be uploaded on the Blackboard or emailed to the concerned lab in charge faculties at the end of the practical in case the there is no Black board access available) Roll No. 50
Name: Divyushii Sinha
Program: B.tech Mechanical
Division: F
Semester: 2
Batch : F3
Date of Experiment:
Date of Submission:
Grade :
1) Algorithm 1. Start 2. Input number N 3. count = 1, sum = 0 4. while (count<=N) 4a. sum = sum + (count*count) 4b. count = count + 1 5. Print sum 6. Stop
Flow Chart
2) Algorithm 1. Start 2. Input numbers X and Y 3. Print 1. Addition 2. Multiplication 3. Division 4. Subtraction 4. Input choice 5. if choice = 1 5a. answer = X+Y 5b. Print answer 6. else if choice = 2 6a. answer = X*Y 6b. Print answer 7. else if choice = 3 7a. answer = X/Y 7b. Print answer 8. else if choice = 4 8a. answer = X – Y 8b. Print answer 9. else
9a. Print invalid choice 10. Stop
Flow Chart
3) Algorithm 1. Start 2. N = 10 3. count = 1 4. while (count <=10) 4a. Print N 4b. N = N – 1 5. count = count + 1 6. Stop
Flow Chart
4) Algorithm 1. Start 2. Input N 3. count = 1, sum =0 4. while (count <= N) 4a. Input num 4b. sum = sum + num 4c. count = count + 1 5. average = sum/N
6. Print average 7. Stop
Flow Chart
5) Algorithm 1. Start 2. Input number X 3. C=2 4. P = X%C 5. If P =0 5a. Print “Not a prime number.” 6. Else 6a. Print “Prime number.” 7. Stop
Flowchart:-
Task 2 Answer : B
B.3 Conclusion:
(Students must write the conclusion as per the attainment of individual outcome listed above and learning/observation)
B.4 Question of Curiosity: