Write algorithm and draw flowchart to read two numbers.

Question

Write an algorithm and draw a flowchart to read two numbers.

    • If both the numbers are negative perform an exponential operation between two numbers
    • If both the numbers are even performed modulus operations between two numbers • Otherwise, display’ Invalid option’.

Explanation

Here we Write an algorithm and draw a flowchart to read two numbers.

If-else block is used to check whether the condition is true or false. So if we have to check between two conditions at that time we use the if-else statement. If the condition is true at that time if block gets executed and if the condition is false else condition gets executed.

The syntax of the if-else block is:

if(condition)
{ //if block statements
}
else
{ //else block statements
}

We use the built-in pow() function to calculate the exponential of the two numbers.

The algorithm required for the above operation is:

    •  Start
    • Take input from user. A and B.
    • Check A<0 && B<0, Set Ans= pow(A,B)
      Else, check A%2==0 && B%2==0, Set Ans=A%B
      Else Process “Invalid Operation”.
    •  Stop

The flowchart for this algorithm will be:

algorithm and draw flowchart

 

Also read, RSA encryption is normally used to encrypt which of the following?

 

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *