Q. Given the following pseudo code:


Use variables: choice, of the type character
ans, number1, number2, of type integer display "choose one of the following"
display "m for multiply"
display "a for add"
display "s for subtract"
accept choice
display "input two numbers you want to use" accept number1, number 2
if choice m then ans number1 number2 if choice a then ans number1 + number 21
if choices then ans number1 - number2
display ans

Draw a flow chart for the same and dry run the given pseudocode if it is working


Answer :-

Program :-
choice = input("Enter your choice( m / s / a ) :- ")
n1 = int(input("Enter number 1 :- ")) 
n2 = int(input("Enter number 2 :- "))
if choice == "m" :
    print("Product of numbers :- ", n1*n2 )
if choice == "s" :
    print("Subtraction of numbers :- " ,n1 - n2 )
if choice == "a" :
    print("Addition of numbers :- ", n1 + n2 )
Output :- 

Enter your choice( m / s / a ) :- m
Enter number 1 :- 4
Enter number 2 :- 5
Product of numbers :-  20
>>>

Enter your choice( m / s / a ) :- a
Enter number 1 :- 8
Enter number 2 :- 3
Addition of numbers :-  11
>>>

Enter your choice( m / s / a ) :- s
Enter number 1 :- 9
Enter number 2 :- 4
Subtraction of numbers :-  5
>>>

Flow Chart :-

Click on image for clear view.

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post