Problem Solving 1
Problem Solving 1
PROBLEM SOLVING
8. What is decomposition?
Ans: Decomposition involves breaking of a complex
problem into smaller parts that are more manageable
and easier to understand. The smaller parts can then be
examined and solved, or designed individually, as they
are simpler to work with.
______**_______
Type- B
8Q. To find the area and perimeter of a rectangle.
Answer :-
Algorithm :-
Flow Chart :-
Answer :-
Algorithm :-
1. Input radius
2. Circumference 2 * 3.14 * radius
3. Area 3.14 * radius ** 2
4. Print Circumference
5. Print Area
6. 7. Stop
Pseudocode :-
Flow Chart :-
10Q. To calculate the simple interest.
Answer :-
Algorithm :-
1. Start
2. Input principal
3. Input rate
4. Input time
5. Simple interest principal * rate * time
6. Print simple interest
7. Stop
Pseudocode :-
Flow Chart :-
11Q. To check whether a year is a leap year or not.
Answer :-
Algorithm :-
1. Start
2. Input Year
3. If year % 4 == 0
Print "leap year "
Else
Print " not leap year "
Pseudocode :-
Flow Chart :-
Answer :-
Algorithm :-
1. Start
2. Input number
3. If number < 0
Print "number is negative"
Else
Print "number is positive"
4. Stop
Pseudocode :-
Flow Chart :-
Answer :-
Algorithm :-
1. Start
2. Input number
3. If number % 2 == 0
4. Print "number is even"
5. Else
6. Print "number odd"
7. Stop
Pseudocode :-
Flow Chart :-
14Q. To categorise a person as either child (<13),
teenager (> 13 but <20) or adult (20), based on age
specified.
Answer :-
Algorithm :-
1. Start
2. Inputage 3. If age < 13
Print
"Child" Elif
age >= 20
Print "adult"
Else
Print "teenager"
4. Stop
Pseudocode :-
A = input "Age "
If a is smaller than 13
Display " Child "
Elif a is greater or equal 20
Display "adult"
Else
Display " teenager "
Flow Chart :-
Answer :-
Algorithm :-
1. Start
2. Input n
3. For I in range ( 1, n + 1 )
Print I
4. Stop
Pseudocode:-
Flow Chart :-
Answer :-
Algorithm :-
1. Start
2. Input n
3. For I in range ( 1 , 2 * n + 1 ) If I % 2 != 0 :
Print I
5. Stop
Pseudocode :-
N = input n
For I in range ( 1 to 2 * n +1)
If I is not divisible by 2
Display I
Flow Chart :-
Algorithm :-
1. Start
2. Input a number
3. Square = number ** 2
4. Print Square
5. Stop
Pseudocode :-
Flow Chart :-
18Q. To accept 5 numbers and find their average.
Answer :-
Algorithm :-
1. Start
2. Input a , b, c , d, e
3. Sum a + b + c + d + e
4. Average Sum / 5
5. Print Average
6. Stop
Pseudocode :-
Flow Chart :-
19Q. To accept numbers till the user enters and then
find their average.
Answer :-
Algorithm :-
1. Start
2. Sum = 0
3. Count = 0
4. While True
Input number
Sum += number
Count += 1
Input choice to quit enter yes
If choice == yes
Break
5. Average = Sum / count
6. Print average
7. Stop
Pseudocode :-
Sum = 0
Count = 0
While True
N = input "Number "
Sum is equal to sum + number
Count is equal to count + number
Choice = input "to quit enter quit"
If choice is equal to quit
Break
Average = sum /
count Display Average
Flow Chart :-
20Q. To print squares of first n numbers.
Answer :-
Algorithm:-
1. Start
2. Input a number
3. For I in range ( number +1 )
Square = I ** 2
Print Square
4. Stop
Pseudocode :-
Flow Chart :-
Answer :-
Algorithm:-
1. Start
2. Input a number
3. Cube = number ** 3
4. Print cube
5. Stop
Pseudocode:-
N = input a number
Cube = n ** 3
Display cube
Flow Chart :-
Answer :-
Algorithm:-
1. Start
2. Input a number
3. For I in range ( number +1 )
Cube = I ** 3
Print cube
4. Stop
Pseudocode :-
Answer :-
Algorithm :-
1. Start
2. Sum = 0
3. While True
Input number
Sum += number
Choice = input to quit enter quit
If choice == quit
Break
4. Print Sum
5. Stop
Pseudocode :-
Sum = 0
While True
N = input a number
Sum equal to sum + n
Choice = input to quit enter quit
If choice is quit
Break
Display sum
Flow Chart :-
Answer :-
Algorithm :-
1. Start
2. Input number
3. Fact = 1
4. For I in range number + 1
Fact *= I
5. Print Fact
Pseudocode :-
N = input a number
Fact is 1
For I in rang n +1
Fact equal to fact * I
Display Fact
Flow Chart :-
Answer :Algorithm
:-
1. Start
2. Input number
3. Fact = 1
4. For I in range number + 1 Fact *= I
5. Print Fact
Pseudocode :-
N = input a number
Fact is 1
For I in rang n
+1 Fact
equal to fact
*I
Display Fact
Flow Chart :-
Draw a flow chart for the same and dry run the given
pseudocode if it is working fine
26Q. Given the following pseudo code:
Draw a flow chart for the same and dry run the given
pseudocode if it is working fine.
28Q.Given the following pseudo code:
Draw a flow chart for the same and dry run the given
pseudocode if it is working fine.
Flowchart
Draw a flow chart for the same and dry run the given
pseudocode if it is working fine.
Answer: