Write an algorithm for the following: a) Input product rate and discount 5 % then display net product rate. b) Input a number and find out if a given number is odd and even.
Answers
Answered by
1
Answer:
No. a :
Start
Enter product rate, p
discounted amount , DA = p*5/100
net amount, NA = p-DA
display net amount, NA
Stop
No. b:
Start
Enter a number, n
(mathematical equation)
if n % 2 == 0
display "even number";
else
display "odd number";
Stop
Explanation:
In no. b:
n%2 (known as modulus) means the remainder which is produced after dividing the number from 2.
if n%2 == 0 , then it is an even number, because there is no remainder
else an odd number
In no. a:
First we calculate the discounted amount and then net amount
Similar questions